1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-02 03:12:25 +01:00

Switch from path-absolutize to path_abs

closes #1022
This commit is contained in:
sharkdp
2020-05-26 07:50:52 +02:00
committed by David Peter
parent 3f6e88b4be
commit bd17fd571f
3 changed files with 16 additions and 23 deletions

View File

@@ -8,7 +8,7 @@ use syntect::dumps::{dump_to_file, from_binary, from_reader};
use syntect::highlighting::{Theme, ThemeSet};
use syntect::parsing::{SyntaxReference, SyntaxSet, SyntaxSetBuilder};
use path_absolutize::Absolutize;
use path_abs::PathAbs;
use crate::assets_metadata::AssetsMetadata;
use crate::error::*;
@@ -220,7 +220,10 @@ 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 = path.absolutize().ok().unwrap_or_else(|| path.to_owned());
let absolute_path = PathAbs::new(path)
.ok()
.map(|p| p.as_path().to_path_buf())
.unwrap_or_else(|| path.to_owned());
match mapping.get_syntax_for(absolute_path) {
Some(MappingTarget::MapToUnknown) => line_syntax.ok_or_else(|| {