Procházet zdrojové kódy

fix: Handle other canonicalize errors in hyperlinks and git

Robert Minsk před 2 roky
rodič
revize
aee393bb82
2 změnil soubory, kde provedl 2 přidání a 2 odebrání
  1. 1 1
      src/fs/feature/git.rs
  2. 1 1
      src/output/file_name.rs

+ 1 - 1
src/fs/feature/git.rs

@@ -332,7 +332,7 @@ fn reorient(path: &Path) -> PathBuf {
 
 #[cfg(windows)]
 fn reorient(path: &Path) -> PathBuf {
-    let unc_path = path.canonicalize().unwrap();
+    let unc_path = path.canonicalize().unwrap_or(path);
     // On Windows UNC path is returned. We need to strip the prefix for it to work.
     let normal_path = unc_path.as_os_str().to_str().unwrap().trim_start_matches("\\\\?\\");
     PathBuf::from(normal_path)

+ 1 - 1
src/output/file_name.rs

@@ -350,7 +350,7 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
 
         let mut display_hyperlink = false;
         if self.options.embed_hyperlinks == EmbedHyperlinks::On {
-            if let Some(abs_path) = self.file.path.canonicalize().unwrap().as_os_str().to_str() {
+            if let Some(abs_path) = self.file.absolute_path.as_ref().and_then(|p| p.as_os_str().to_str()) {
                 bits.insert(0, ANSIString::from(format!(
                     "{}file://{}{}{}",
                     HYPERLINK_START,