Skip to content

fix(syntax): empty phrases, comparisons in angle groups, empty groups, literal quoted wildcards - #234

Open
vlasky wants to merge 6 commits into
cardisoft:masterfrom
vlasky:fix/query-syntax
Open

vlasky wants to merge 6 commits into
cardisoft:masterfrom
vlasky:fix/query-syntax

Conversation

@vlasky

@vlasky vlasky commented Oct 26, 2026 •

Copy link
Copy Markdown
  • foo "" bar failed with "unexpected trailing characters": parse_and treated an empty operand as end of input. Skip it and keep parsing.
  • <size:>1gb> failed because the group closer check consumed the comparison's >. Read > as an operator when an operand follows it directly.
  • () / <> was only rejected by accident and only when more input followed; it is now an explicit "empty group" error.
  • search-syntax.md says quoting makes wildcards literal ("*.rs"), but quote stripping ran before matcher construction, so "*.rs" matched every .rs file. Quoted */? are now emitted as \*/\? by the preprocessor and treated as literals by the segment matcher and the highlight collector. Filter arguments keep plain quote stripping.

Note: the last item changes observable behaviour for anyone relying on quoted wildcards still acting as wildcards; it brings the implementation in line with the documented syntax.

Commands run: cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace.

Follow-up after review: user-typed backslashes are preserved (foo\*.txt still means a backslash followed by a wildcard; literal backslashes travel as \\ internally), and > is read as a comparison inside angle groups only for comparison-capable filters, so <folder:>foo and <folder:><ext:rs> keep working. Parser regression tests and an end-to-end search test were added.
A third commit applies the same encoding to file: / folder: / type-macro arguments, which share the matcher.
Later commits make highlight terms for those arguments follow the same rules as bare words.
One pre-existing highlight oddity found during review is fixed too: foo/?? no longer emits the unmatched term foo/.

…, literal quoted wildcards

- `foo "" bar` failed with "unexpected trailing characters": parse_and
  treated an empty operand as end of input. Skip it and keep parsing.
- `<size:>1gb>` failed because the group closer check consumed the
  comparison's `>`. Read `>` as an operator when an operand follows it
  directly.
- `()` / `<>` was only rejected by accident and only when more input
  followed; it is now an explicit "empty group" error.
- search-syntax.md says quoting makes wildcards literal (`"*.rs"`), but
  quote stripping ran before matcher construction, so `"*.rs"` matched
  every .rs file. Quoted `*`/`?` are now emitted as `\*`/`\?` by the
  preprocessor and treated as literals by the segment matcher and the
  highlight collector. Filter arguments keep plain quote stripping.

Note: the last item changes observable behaviour for anyone relying on
quoted wildcards still acting as wildcards; it brings the implementation
in line with the documented syntax.

Commands run: cargo fmt --all -- --check, cargo clippy --workspace
--all-targets -- -D warnings, cargo test --workspace.
…isons to comparison filters

- A user-typed backslash before a wildcard (`foo\*.txt`) was swallowed
  by the new `\*` escape and turned the wildcard literal. The
  preprocessor now emits literal backslashes as `\\`, which the segment
  matcher and highlighter decode, so generated escapes cannot collide
  with backslashes in file names.
- Inside angle groups, `>` followed by any character was read as a
  comparison operator for every filter, breaking `<folder:>foo` and
  `<folder:><ext:rs>`. Only comparison-capable filters (size, dates,
  width/height/dimensions/bitdepth, year, track) now take it as an
  operator.
- Add parser regression tests and an end-to-end search test covering
  quoted wildcards, backslash file names and globstar in both case
  modes.
Their arguments are matched through the same segment matcher as bare
words, which now decodes `\\` and `\*`. With plain quote stripping a
typed `folder:"a\\\\b"` was unescaped twice and no longer matched a
folder named `a\\b`. Give these arguments the word encoding, so quoted
wildcards are literal and backslashes survive, and cover it with an
end-to-end test.
`file:"*.rs"` now matches the literal name, but its highlight term kept
the encoded `\*.rs` and never highlighted the matched file. Decode the
word encoding for quoted arguments of the matcher-backed filters, with
the kind set shared with the preprocessor.
…are words

The matcher evaluates a file:/folder:/type-macro argument as a single
name pattern whatever the parser classified it as, so the highlighter
must do the same: partial quotes (`file:"foo"*`), lists and trailing
globstars now produce the same terms as their unquoted forms, and the
separate phrase decoder is gone.
… term

`foo/??` highlighted `foo/`, which can never match a file name: when the
last path segment produced no literal chunks the collector fell back to
chunking the whole query. Treat such a segment like `*` and `**` and
keep the raw-text fallback only for a query with no segments at all.
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.

1 participant