Repository navigation
fix(completion): the expanded path prefix is never globbed - #1057
Merged
Merged
Conversation
Completion globbed the expanded cwd/prefix together with the user pattern, so
`[ ] { } * ? \` and extglob operators in a cwd, a `~`/`$VAR` value or a quoted
prefix were treated as pattern syntax. In `... [10-Raw26 ...]`, exact
completion returned nothing; GlobExpansion, `./` and FirstWord path completion
were affected too.
The expanded prefix is now the literal base directory for `GlobIterator`,
which parses only `rhs_pattern`, and `dequote_glob_pattern()` keeps quoted or
escaped metacharacters escaped, including quote state across the split and the
synthetic prefix `*`.
Tests cover a temporary cwd and entries containing `[ ] { } * ? \`, escaped
and quoted names, and quoted directory prefixes.
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.
Summary
Completion globbed the expanded cwd/prefix together with the user pattern, so
[ ] { } * ? \and extglob operators in a cwd, a~/$VARvalue or a quotedprefix were treated as pattern syntax. In
... [10-Raw26 ...], exactcompletion returned nothing.
PathPatternExpansion::base_dir()is now the literal directory forGlobIterator; onlyrhs_patternis parsed, and literal segments areunescaped.
dequote_glob_pattern()keeps quoted/escaped metacharacters escaped,carries quote state across the prefix/pattern split, and leaves the synthetic
prefix
*a wildcard inside an unclosed quote.Repro
Tests
cargo test --lib(896 passed), fmt, clippy and rustdoc pass. New tests covera cwd and entries containing
[ ] { } * ? \, escaped/quoted names(
lit\[1\].txt,"lit[1].txt) and quoted directory prefixes(
"sub [1]/fi,sub\ \[1\]/fi).