From 83b05f1cbba7ab38d2aaae869ecfc3fef57cfcc0 Mon Sep 17 00:00:00 2001 From: xcb3d <122720156+xcb3d@users.noreply.github.com> Date: Wed, 4 Mar 2026 23:42:14 +0700 Subject: [PATCH] Fix terminal path click failing when path is prefixed with '0:' (#50663) The path hyperlink regex's middle-char pattern [[:(][^0-9()]](cci:2://file:///d:/zed/crates/fs/src/fs.rs:89:0-157:1) allowed colon+space because space was not in the exclusion set. This caused `0: foo/bar.txt` to be matched as a single path instead of just `foo/bar.txt`. Fix: add space to the exclusion class: [[:(][^0-9()\\ ]](cci:2://file:///d:/zed/crates/fs/src/fs.rs:89:0-157:1) Closes #50531 - [x] Added a solid test coverage and/or screenshots from doing manual testing - [x] Done a self-review taking into account security and performance aspects - [ ] Aligned any UI changes with the [UI checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) (N/A) Release Notes: - Fixed terminal Ctrl-click path detection failing when path is preceded by a prefix like `0:` (#50531) --- assets/settings/default.json | 4 ++-- crates/terminal/src/terminal_hyperlinks.rs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index b193c0f60d0087972381f4f85f2b864b52fdbc7d..6593c3b192cb9ac388c67170fe20787bdbcf1bbc 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -1831,8 +1831,8 @@ " (", " # 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()])*", + " # middle chars: non-space, and colon/paren only if not followed by digit/paren/space", + " ([^\\ :(]|[:(][^0-9()\\ ])*", " # last char: not closing delimiter or colon", " [^()}\\]>\"'`.,;:\\ ]", " |", diff --git a/crates/terminal/src/terminal_hyperlinks.rs b/crates/terminal/src/terminal_hyperlinks.rs index d239f680f9e2ecbd3d320e731d3cc74303a552ed..0ca6cb2edd916019a4a7822830faa1fdfaa238f3 100644 --- a/crates/terminal/src/terminal_hyperlinks.rs +++ b/crates/terminal/src/terminal_hyperlinks.rs @@ -905,6 +905,18 @@ mod tests { ); } + #[test] + // + fn issue_50531() { + // Paths preceded by "N:" prefix (e.g. grep output line numbers) + // should still be clickable + test_path!("0: ‹«foo/👉bar.txt»›"); + test_path!("0: ‹«👉foo/bar.txt»›"); + test_path!("42: ‹«👉foo/bar.txt»›"); + test_path!("1: ‹«/👉test/cool.rs»›"); + test_path!("1: ‹«/👉test/cool.rs»:«4»:«2»›"); + } + #[test] // fn issue_46795() {