From fc6f8d5706b5ea123ac6bd15b275dee44133e7fa Mon Sep 17 00:00:00 2001 From: Yao Xiao <108576690+Charlie-XIAO@users.noreply.github.com> Date: Fri, 13 Feb 2026 11:19:43 -0500 Subject: [PATCH] terminal: Fix hyperlinks not being detected correctly when preceded by box-drawing chars (#48447) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #46795 This PR aims to correctly detect the hyperlinks in cases like the following, where box-drawing characters immediately precede the path (without spaces in between). ``` ╭─[Cargo.toml:55:1] ... ╰──── ``` The only false negative with the fix in this PR would be that a file path really contains leading box drawing characters which I think is very unlikely. --- Release Notes: - Fixed an issue where the hyperlinks would not be properly detected in the terminal if they were preceded by box-drawing characters (like ─, │, ┌, ┐) Signed-off-by: Charlie-XIAO --- assets/settings/default.json | 8 ++++---- crates/terminal/src/terminal_hyperlinks.rs | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index 0d1762ea2adffa245f8eca5e2e8de233e6ed328d..111b42cdcc561a046254305662c5bfc2f0916e6e 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -1797,15 +1797,15 @@ "(?x)", "(?", " (", - " # multi-char path: first char (not opening delimiter or space)", - " [^({\\[<\"'`\\ ]", + " # multi-char path: first char (not opening delimiter, space, or box drawing char)", + " [^({\\[<\"'`\\ \\u2500-\\u257F]", " # middle chars: non-space, and colon/paren only if not followed by digit/paren", " ([^\\ :(]|[:(][^0-9()])*", " # last char: not closing delimiter or colon", " [^()}\\]>\"'`.,;:\\ ]", " |", - " # single-char path: not delimiter, punctuation, or space", - " [^(){}\\[\\]<>\"'`.,;:\\ ]", + " # single-char path: not delimiter, punctuation, space, or box drawing char", + " [^(){}\\[\\]<>\"'`.,;:\\ \\u2500-\\u257F]", " )", " # optional line/column suffix (included in path for PathWithPosition::parse_str)", " (:+[0-9]+(:[0-9]+)?|:?\\([0-9]+([,:]?[0-9]+)?\\))?", diff --git a/crates/terminal/src/terminal_hyperlinks.rs b/crates/terminal/src/terminal_hyperlinks.rs index 5250dfb1a99cdff11da7fa75665801609ff50299..d239f680f9e2ecbd3d320e731d3cc74303a552ed 100644 --- a/crates/terminal/src/terminal_hyperlinks.rs +++ b/crates/terminal/src/terminal_hyperlinks.rs @@ -905,6 +905,23 @@ mod tests { ); } + #[test] + // + fn issue_46795() { + // Box drawing characters are commonly used as UI elements and + // should not interfere with path detection; they appear rarely + // enough in actual paths that false positives should be minimal + + test_path!("─‹«/👉test/cool.rs»:«4»:«2»›"); + test_path!("┤‹«/👉test/cool.rs»:«4»:«2»›"); + test_path!("╿‹«/👉test/cool.rs»:«4»:«2»›"); + + test_path!("└──‹«/👉test/cool.rs»:«4»:«2»›"); + test_path!("├─[‹«/👉test/cool.rs»:«4»:«2»›]"); + test_path!("─[‹«/👉test/cool.rs»:«4»:«2»›]"); + test_path!("┬‹«/👉test/cool.rs»:«4»:«2»›┬"); + } + #[test] #[cfg_attr( not(target_os = "windows"),