rust-bat/0001-port-from-path_abs-to-...

40 lines
1.2 KiB
Diff

From 6639f0061b39a21ae2e3bcfca21c7915319039db Mon Sep 17 00:00:00 2001
From: Fabio Valentini <decathorpe@gmail.com>
Date: Thu, 21 Jul 2022 10:45:26 +0200
Subject: [PATCH] port from path_abs to path-absolutize
---
src/assets.rs | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/assets.rs b/src/assets.rs
index 8126843..f578d70 100644
--- a/src/assets.rs
+++ b/src/assets.rs
@@ -1,3 +1,4 @@
+use std::borrow::Cow;
use std::ffi::OsStr;
use std::fs;
use std::path::Path;
@@ -7,7 +8,7 @@ use once_cell::unsync::OnceCell;
use syntect::highlighting::Theme;
use syntect::parsing::{SyntaxReference, SyntaxSet};
-use path_abs::PathAbs;
+use path_absolutize::Absolutize;
use crate::error::*;
use crate::input::{InputReader, OpenedInput};
@@ -224,7 +225,7 @@ impl HighlightingAssets {
let path = input.path();
let path_syntax = if let Some(path) = path {
self.get_syntax_for_path(
- PathAbs::new(path).map_or_else(|_| path.to_owned(), |p| p.as_path().to_path_buf()),
+ path.absolutize().unwrap_or(Cow::Borrowed(path)),
mapping,
)
} else {
--
2.37.1