Repository navigation
Skip paths starting with // in file link detection - #759
Merged
Merged
Conversation
A path candidate beginning with // is almost never a file. In terminal output it is a // code comment, which linked to the root directory because // is an existing absolute path, or the host half of a URL whose scheme the URL pass does not cover, such as npm's `//registry.example.com/` warnings or ws://localhost:8080. On Windows and Cygwin a //HOST/... name is a UNC network share. Emacs's file-exists-p resolves it through GetFileAttributes, which looks the host up over the network and blocks for seconds when the host does not answer. The seen-cache is per scan, so every redraw covering such a line paid that cost again, freezing Emacs each time the buffer was shown. The guard runs on the raw match before expand-file-name, so relative paths in a shell whose cwd is a share still expand onto that share and link. Only absolute //server/share/... text stops linking, as does a doubled slash like //bin/sh on POSIX. Closes #755.
dakra
force-pushed
the
fix/skip-double-slash-paths
branch
from
October 24, 2026 11:05
a1a2db1 to
e71226b
Compare
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative to #757 with a smaller footprint. Closes #755.
A path candidate starting with
//is almost never a file. In terminal output it is a//code comment (which linked to the root directory, since//is an existing absolute path) or the host half of a URL whose scheme the URL pass does not cover, such as npm's//registry.example.com/warnings orws://localhost:8080. On Windows and Cygwin it names a UNC share, andfile-exists-presolves it throughGetFileAttributes, which looks the host up over the network and blocks for seconds when the host does not answer. The per-scanseencache meant every redraw covering such a line paid again.The fix is one extra disjunct in the file-pass guard, checked on the raw match before
expand-file-nameand the stat. Nosystem-typebranch: the junk candidates cost a stat on every platform, and skipping them is cheaper everywhere.Ghostty's own path detection already behaves this way: the absolute-path branch of its URL regex (
src/config/url.zig) requires a/that is not followed by another/, so//paths are never candidates there either.Compared with #757, which compares the candidate's host against the host
default-directoryis on, this drops the same-host exception. Relative paths in a shell whose cwd is a share still expand onto the share after the check and link as before. Only absolute//server/share/...text in output stops linking.Behaviour
link = linkified when the file exists. stat = no link, one cheap local stat. skip = no link, no stat. HANG = Windows blocks on a network lookup for seconds, every scan.
Linux and macOS, any cwd
/etc/hosts,src/main.rs:42:4,./a.el:3,~/.zshrc// comment here//to///bin/sh(kernel reads it as/bin/sh)//registry.example.com/api/ws://localhost:8080/socket//localhostWindows, cwd on a local drive such as
c:/src/c:/src/a.el,./a.el:3,src/main.rs:42//registry.example.com/api/, host unreachable//server/share/proj/b.el, server reachable//server/share/proj/b.el, server unreachableWindows, cwd on a share,
//server/share/proj/./a.el:3,b.el,../x/y.el//server/share/proj/b.el//otherserver/share/x.el, unreachable//registry.example.com/api/Cost
Measured in
emacs -Q --batch: the guard is onestring-prefix-pper candidate. On a 1.3 MB sample of mixed output it removed 20% of the candidates, each of which previously cost a stat, so scans get slightly faster.Tests
One new test, running on every platform: an npm-style
//registry.example.com/api/, a bare//from a comment, and a real fixture file on one line. It asserts no//path reachesfile-exists-pand only the fixture file links. The test fails with the guard removed.