on master help sign in
Use absolute path for lookup in database
commit57aed0781447c21fd3cf270509326c0010f132e5 authorsharkdp <davidpeter@web.de> dateSun 22 Mar 2020, 10:19 (7 years ago) parentbd8a13d
1 file changed+3−2
src/assets.rs+3−2
src/assets.rs+3−2
@@ -196,8 +196,8 @@ impl HighlightingAssets {
196196 .ok()
197197 .and_then(|l| self.syntax_set.find_syntax_by_first_line(&l));
198198
199− dbg!(path);
200− match dbg!(mapping.get_syntax_for(path)) {
199+ let absolute_path = path.canonicalize().ok().unwrap_or(path.to_owned());
200+ match mapping.get_syntax_for(absolute_path) {
201201 Some(MappingTarget::MapTo(syntax_name)) => {
202202 // TODO: we should probably return an error here if this syntax can not be
203203 // found. Currently, we just fall back to 'plain'.
@@ -275,6 +275,7 @@ mod tests {
275275
276276 assert_eq!(test.syntax_name("test.rs"), "Rust");
277277 assert_eq!(test.syntax_name("test.cpp"), "C++");
278+ assert_eq!(test.syntax_name("test.build"), "NAnt Build File");
278279 assert_eq!(test.syntax_name("PKGBUILD"), "Bourne Again Shell (bash)");
279280 assert_eq!(test.syntax_name(".bashrc"), "Bourne Again Shell (bash)");
280281 assert_eq!(test.syntax_name("Makefile"), "Makefile");