mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-31 04:39:01 +00:00
url: exclude trailing spaces from path matches
#13491 #9921 Path matching previously included end-of-line spaces. Pi redraws can leave blank cells after a path, causing cmd-click to open a pathname that includes those cells. Do not include trailing whitespace in path matches. AI disclosure: Pi using GPT-5.6 Terra High was used to investigate and write this change. I reviewed it personally.
This commit is contained in:
@@ -52,10 +52,6 @@ const no_trailing_colon =
|
||||
\\(?<!:)
|
||||
;
|
||||
|
||||
const trailing_spaces_at_eol =
|
||||
\\(?: +(?= *$))?
|
||||
;
|
||||
|
||||
const dotted_path_lookahead =
|
||||
\\(?=[\w\-.~:\/?#@!$&*+;=%]*\.)
|
||||
;
|
||||
@@ -92,13 +88,11 @@ const rooted_or_relative_path_branch =
|
||||
path_chars ++ "+" ++
|
||||
dotted_path_space_segments ++
|
||||
no_trailing_colon ++
|
||||
trailing_spaces_at_eol ++
|
||||
"|" ++
|
||||
non_dotted_path_lookahead ++
|
||||
path_chars ++ "+" ++
|
||||
any_path_space_segments ++
|
||||
no_trailing_colon ++
|
||||
trailing_spaces_at_eol ++
|
||||
")";
|
||||
|
||||
// Branch 3: Bare relative paths such as src/config/url.zig.
|
||||
@@ -110,8 +104,7 @@ const bare_relative_path_branch =
|
||||
dotted_path_lookahead ++
|
||||
bare_relative_path_prefix ++
|
||||
path_chars ++ "+" ++
|
||||
no_trailing_colon ++
|
||||
trailing_spaces_at_eol;
|
||||
no_trailing_colon;
|
||||
|
||||
pub const regex =
|
||||
scheme_url_branch ++
|
||||
@@ -282,7 +275,7 @@ test "url regex" {
|
||||
},
|
||||
.{
|
||||
.input = "../example.py ",
|
||||
.expect = "../example.py ",
|
||||
.expect = "../example.py",
|
||||
},
|
||||
.{
|
||||
.input = "first time ../example.py contributor ",
|
||||
@@ -341,11 +334,12 @@ test "url regex" {
|
||||
.input = "IPv6 in markdown [link](http://[2001:db8::1]/docs)",
|
||||
.expect = "http://[2001:db8::1]/docs",
|
||||
},
|
||||
// File paths with spaces
|
||||
// Trailing whitespace isn't part of a detected file path.
|
||||
.{
|
||||
.input = "./spaces-end. ",
|
||||
.expect = "./spaces-end. ",
|
||||
.expect = "./spaces-end.",
|
||||
},
|
||||
// File paths with internal spaces
|
||||
.{
|
||||
.input = "./space middle",
|
||||
.expect = "./space middle",
|
||||
|
||||
Reference in New Issue
Block a user