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.
59 lines
2.0 KiB
59 lines
2.0 KiB
5 years ago
|
From 19996e8fdf180260ff618479ff163cbc4ecfc23c 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>
|
||
|
---
|
||
|
Cargo.toml | 2 +-
|
||
|
src/assets.rs | 8 +++-----
|
||
|
2 files changed, 4 insertions(+), 6 deletions(-)
|
||
|
|
||
|
diff --git a/Cargo.toml b/Cargo.toml
|
||
|
index 949375b..53804d2 100644
|
||
|
--- a/Cargo.toml
|
||
|
+++ b/Cargo.toml
|
||
|
@@ -51,7 +51,7 @@ globset = "0.4"
|
||
|
serde = { version = "1.0", features = ["derive"] }
|
||
|
serde_yaml = "0.8"
|
||
|
semver = "0.10"
|
||
|
-path_abs = { version = "0.5", default-features = false }
|
||
|
+path-absolutize = { version = "3", features = ["lazy_static_cache"] }
|
||
|
|
||
|
[dependencies.git2]
|
||
|
version = "0.13"
|
||
|
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_binary, from_reader};
|
||
|
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::error::*;
|
||
|
@@ -216,10 +217,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
|
||
|
|