Skip to content

fix(completion): the expanded path prefix is never globbed - #1057

Merged
HalFrgrd merged 2 commits into
HalFrgrd:masterfrom
lenitain:fix/literal-glob-base
Nov 7, 2026
Merged

HalFrgrd merged 2 commits into
HalFrgrd:masterfrom
lenitain:fix/literal-glob-base

Conversation

@lenitain

@lenitain lenitain commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Summary

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.

  • PathPatternExpansion::base_dir() is now the literal directory for
    GlobIterator; only rhs_pattern is parsed, and literal segments are
    unescaped.
  • 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

mkdir -p '/tmp/aa [1] {b,c} *d?'; cd '/tmp/aa [1] {b,c} *d?'; touch alpha.txt
qutebrowser <TAB>        # was 0 candidates, now alpha.txt
qutebrowser alpha.*<TAB> # was 0 candidates, now alpha.txt
qutebrowser ./<TAB>      # was 0 candidates, now alpha.txt

Tests

cargo test --lib (896 passed), fmt, clippy and rustdoc pass. New tests cover
a cwd and entries containing [ ] { } * ? \, escaped/quoted names
(lit\[1\].txt, "lit[1].txt) and quoted directory prefixes
("sub [1]/fi, sub\ \[1\]/fi).

lenitain and others added 2 commits November 3, 2026 19:32
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.

@HalFrgrd HalFrgrd left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@HalFrgrd
HalFrgrd merged commit 955f89c into HalFrgrd:master Nov 7, 2026
@lenitain
lenitain deleted the fix/literal-glob-base branch November 8, 2026 02:22
@lenitain
lenitain restored the fix/literal-glob-base branch November 8, 2026 02:22
@lenitain
lenitain deleted the fix/literal-glob-base branch November 8, 2026 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants