Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
terminal: Fix hyperlinks not being detected correctly when preceded by box-drawing chars (#48447)
Yao Xiaofc6f8d5706b5
diff --git a/assets/settings/default.json b/assets/settings/default.jsonindex 0d1762ea2ad..111b42cdcc5 100644--- a/assets/settings/default.json+++ b/assets/settings/default.json@@ -1797,15 +1797,15 @@"(?x)","(?<path>"," (",- " # 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.rsindex 5250dfb1a99..d239f680f9e 100644--- a/crates/terminal/src/terminal_hyperlinks.rs+++ b/crates/terminal/src/terminal_hyperlinks.rs@@ -905,6 +905,23 @@ mod tests {);}+ #[test]+ // <https://github.com/zed-industries/zed/issues/46795>+ 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"),