summaryrefslogtreecommitdiffstats
path: root/src/assets.rs
diff options
context:
space:
mode:
authorsharkdp <davidpeter@web.de>2020-03-22 10:19:35 +0100
committerDavid Peter <sharkdp@users.noreply.github.com>2020-03-22 11:02:51 +0100
commit57aed0781447c21fd3cf270509326c0010f132e5 (patch)
tree3437b4e1d81fa2a14c37ee0e0237f603b82e4126 /src/assets.rs
parentbd8a13dbc920b8739ef0f5e3fa84d90b3a24608b (diff)
Use absolute path for lookup in database
Diffstat (limited to 'src/assets.rs')
-rw-r--r--src/assets.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/assets.rs b/src/assets.rs
index 73491aac..4d4bd184 100644
--- a/src/assets.rs
+++ b/src/assets.rs
@@ -196,8 +196,8 @@ impl HighlightingAssets {
.ok()
.and_then(|l| self.syntax_set.find_syntax_by_first_line(&l));
- dbg!(path);
- match dbg!(mapping.get_syntax_for(path)) {
+ let absolute_path = path.canonicalize().ok().unwrap_or(path.to_owned());
+ match mapping.get_syntax_for(absolute_path) {
Some(MappingTarget::MapTo(syntax_name)) => {
// TODO: we should probably return an error here if this syntax can not be
// found. Currently, we just fall back to 'plain'.
@@ -275,6 +275,7 @@ mod tests {
assert_eq!(test.syntax_name("test.rs"), "Rust");
assert_eq!(test.syntax_name("test.cpp"), "C++");
+ assert_eq!(test.syntax_name("test.build"), "NAnt Build File");
assert_eq!(test.syntax_name("PKGBUILD"), "Bourne Again Shell (bash)");
assert_eq!(test.syntax_name(".bashrc"), "Bourne Again Shell (bash)");
assert_eq!(test.syntax_name("Makefile"), "Makefile");