You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.6 KiB
45 lines
1.6 KiB
From d565131b04db44067f1bf07eafc863022c6b7c55 Mon Sep 17 00:00:00 2001
|
|
From: Igor Raits <i.gnatenko.brain@gmail.com>
|
|
Date: Sun, 21 Jun 2020 10:16:03 +0200
|
|
Subject: [PATCH] Siwtch to path-absolutize
|
|
|
|
This reverts commit bd17fd571f99d52b4d76a24aee719dcd89a0244d.
|
|
Signed-off-by: Igor Raits <i.gnatenko.brain@gmail.com>
|
|
---
|
|
src/assets.rs | 8 +++-----
|
|
1 file changed, 3 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/src/assets.rs b/src/assets.rs
|
|
index 86c3fe0..3899d7c 100644
|
|
--- a/src/assets.rs
|
|
+++ b/src/assets.rs
|
|
@@ -1,3 +1,4 @@
|
|
+use std::borrow::Cow;
|
|
use std::collections::BTreeMap;
|
|
use std::ffi::OsStr;
|
|
use std::fs::{self, File};
|
|
@@ -8,7 +9,7 @@ use syntect::dumps::{dump_to_file, from_
|
|
use syntect::highlighting::{Theme, ThemeSet};
|
|
use syntect::parsing::{SyntaxReference, SyntaxSet, SyntaxSetBuilder};
|
|
|
|
-use path_abs::PathAbs;
|
|
+use path_absolutize::Absolutize;
|
|
|
|
use crate::assets_metadata::AssetsMetadata;
|
|
use crate::bat_warning;
|
|
@@ -255,10 +256,7 @@ impl HighlightingAssets {
|
|
if let Some(path_str) = path_str {
|
|
// If a path was provided, we try and detect the syntax based on extension mappings.
|
|
let path = Path::new(path_str);
|
|
- let absolute_path = PathAbs::new(path)
|
|
- .ok()
|
|
- .map(|p| p.as_path().to_path_buf())
|
|
- .unwrap_or_else(|| path.to_owned());
|
|
+ let absolute_path = path.absolutize().unwrap_or(Cow::Borrowed(path));
|
|
|
|
match mapping.get_syntax_for(absolute_path) {
|
|
Some(MappingTarget::MapToUnknown) => line_syntax.ok_or_else(|| {
|
|
--
|
|
2.27.0
|
|
|