Repository navigation
Skip paths starting with /\ in file link detection - #854
Merged
Merged
Conversation
On Windows a backslash is a directory separator, so `expand-file-name' turns a candidate such as the regex `/\r/g' into the network share `//r/g', and `file-exists-p' blocks for seconds looking up the host. The guard that skips `//' candidates tests the raw match, which let these through. Closes #853.
This branch was successfully 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.
Closes #853.
The file pass of link detection skips candidates starting with
//, because on Windows they name a network share andfile-exists-pblocks for seconds looking up the host. That guard tests the raw match. On Windows a backslash is also a directory separator, andexpand-file-namenormalises it to a slash, so a candidate such as the regex/\r/gpassed the guard, expanded to//r/g, and hit the same lookup.The guard now skips candidates starting with
/\as well. It stays on the raw match: a relative path in a shell whose cwd is on a share still expands onto the share afterwards and links as before.Behaviour
s.replace(/\r/g, '')rx = /\d+/.test(y)d+split(/\s*,\s*/)sed 's/\r//'(relatives/\r/)/etc/hosts,src/main.rs:42:4,./a.el:3,~/.zshrcWith the shipped
ghostel-file-detection-path-regexa candidate cannot start with a backslash, so//and/\are the only shapes that expand to a share. Doubled separators later in a path collapse to one, sinceexpand-file-namepreserves//only at the very start of a name.On Linux and macOS these candidates are skipped too, which saves one stat per regex literal. The only link lost is to a file directly under
/whose name starts with a backslash.Tests
One new test, running on every platform: a line with
/\r/g,/\d+/.testand a real fixture file. It asserts no/\or//path reachesfile-exists-pand only the fixture links. It fails with the guard change reverted.The hang itself was not reproduced on Windows; the Windows behaviour is taken from
Fexpand_file_namein the Emacs source.