mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-14 19:45:49 +00:00
Related to #1972 The URL regex for file path detection requires paths to start with `../`, `./`, or `/`. For bare relative paths like `"src/config/url.zig"`, the regex could only match starting at the first `/`, producing `"/config/url.zig"` as a result — always dropping the first part of the path. Fix: added a third top-level alternative to the regex. This matches bare relative paths where: 1. The first component is word characters (possibly with dots/dashes): `[\w][\w\-.]*\/` 2. The remaining path must contain a dot (via positive lookahead) — this requires a file extension to avoid false positives on text like input/output 3. Add a `(?<!\w)\/` instead of `\/` in the existing prefix group — the standalone `/` prefix now requires that `/` is not preceded by a word character. This prevents `"input/output"` from falsely matching `"/output"` Test cases added: - src/config/url.zig → matches fully - app/folder/file.rb:1 → matches with line number - modified: src/config/url.zig → matches only the path part - lib/ghostty/terminal.zig:42:10 → matches with line:col - some-pkg/src/file.txt more text → stops before trailing text - input/output and foo/bar → correctly do not match (no file extension) The issue was nailed down here: https://github.com/ghostty-org/ghostty/issues/1972#issuecomment-3845717672