Skip to content

Commit d879d4d

Browse files
committed
Exclude terminal padding from implicit links
1 parent c74d1e6 commit d879d4d

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

Sources/SwiftTerm/Terminal.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7423,7 +7423,6 @@ open class Terminal {
74237423
let pathChars = #"[\w\-.~:\/?#@!$&*+;=%]"#
74247424
let noTrailingPunctuation = #"(?<![,.])"#
74257425
let noTrailingColon = #"(?<!:)"#
7426-
let trailingSpacesAtEOL = #"(?: +(?= *$))?"#
74277426
let dottedPathLookahead = #"(?=[\w\-.~:\/?#@!$&*+;=%]*\.)"#
74287427
let nonDottedPathLookahead = #"(?![\w\-.~:\/?#@!$&*+;=%]*\.)"#
74297428
let dottedPathSpaceSegments = #"(?:(?<!:) (?!\w+:\/\/)[\w\-.~:\/?#@!$&*+;=%]*[\/.])*"#
@@ -7459,13 +7458,11 @@ open class Terminal {
74597458
pathChars + "+" +
74607459
dottedPathSpaceSegments +
74617460
noTrailingColon +
7462-
trailingSpacesAtEOL +
74637461
"|" +
74647462
nonDottedPathLookahead +
74657463
pathChars + "+" +
74667464
anyPathSpaceSegments +
74677465
noTrailingColon +
7468-
trailingSpacesAtEOL +
74697466
")"
74707467

74717468
// Ghostty uses (?<!\$\d*) here, which is unsupported by ICU.
@@ -7476,8 +7473,7 @@ open class Terminal {
74767473
bareRelativePathPrefix +
74777474
pathChars + "+" +
74787475
dottedPathSpaceSegments +
7479-
noTrailingColon +
7480-
trailingSpacesAtEOL
7476+
noTrailingColon
74817477

74827478
let regex = schemeURLBranch + "|" + rootedOrRelativePathBranch + "|" + bareRelativePathBranch
74837479
return try? NSRegularExpression(pattern: regex, options: [])

Tests/SwiftTermTests/GhosttyImplicitLinkDetectionTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ final class GhosttyImplicitLinkDetectionTests: TerminalDelegate {
7676
("IPv6 address https://[2001:db8::1]:8080/path", "https://[2001:db8::1]:8080/path"),
7777
("IPv6 address https://[2001:db8::1]:8080(foo)", "https://[2001:db8::1]:8080"),
7878
("../example.py", "../example.py"),
79-
("../example.py ", "../example.py "),
79+
("../example.py ", "../example.py"),
8080
("first time ../example.py contributor ", "../example.py"),
8181
("src/config/url.zig", "src/config/url.zig"),
8282
("app/folder/file.rb:1", "app/folder/file.rb:1"),
@@ -90,7 +90,7 @@ final class GhosttyImplicitLinkDetectionTests: TerminalDelegate {
9090
(" - shared/src/foo/SomeItem.m:12, shared/src/", "shared/src/foo/SomeItem.m:12"),
9191
("foo.local/share", "foo.local/share"),
9292
("2024/report.txt", "2024/report.txt"),
93-
("./spaces-end. ", "./spaces-end. "),
93+
("./spaces-end. ", "./spaces-end."),
9494
("./space middle", "./space middle")
9595
]
9696

0 commit comments

Comments
 (0)