diff options
author | Dan Davison <dandavison7@gmail.com> | 2022-02-14 12:30:30 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-14 12:30:30 -0500 |
commit | 3d5b6852a06e4aaf2ae8e3b02a3b2e4e59429f22 (patch) | |
tree | bf8614847eecec3541b10f26b42f368ebbed0e27 /src/features/line_numbers.rs | |
parent | b66d1d371709205525128fcd80ca302630f8ac9e (diff) |
Fix hyperlink absolute paths (#939)0.12.0
Fix file paths and hyperlinks
With this commit the target of a hyperlink should always be an absolute path. This should be true for all file hyperlinks, e.g.
- File hyperlink
- Hunk header hyperlink
- Line number hyperlink
Fixes #890
Diffstat (limited to 'src/features/line_numbers.rs')
-rw-r--r-- | src/features/line_numbers.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/features/line_numbers.rs b/src/features/line_numbers.rs index f80b02df..88850434 100644 --- a/src/features/line_numbers.rs +++ b/src/features/line_numbers.rs @@ -12,6 +12,7 @@ use crate::features::OptionValueFunction; use crate::format::{self, Align, Placeholder}; use crate::minusplus::*; use crate::style::Style; +use crate::utils; pub fn make_feature() -> Vec<(String, OptionValueFunction)> { builtin_feature!([ @@ -304,9 +305,13 @@ fn format_line_number( let pad = |n| format::pad(n, width, alignment, precision); match (line_number, config.hyperlinks, plus_file) { (None, _, _) => " ".repeat(width), - (Some(n), true, Some(file)) => { - hyperlinks::format_osc8_file_hyperlink(file, line_number, &pad(n), config).to_string() - } + (Some(n), true, Some(file)) => match utils::path::absolute_path(file, config) { + Some(absolute_path) => { + hyperlinks::format_osc8_file_hyperlink(absolute_path, line_number, &pad(n), config) + .to_string() + } + None => file.to_owned(), + }, (Some(n), _, _) => pad(n), } } |