Repository navigation
fix: suppress zsh NOMATCH errors in completion function - #3
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (4)
📜 Recent review details⏰ Context from checks skipped due to timeout of 18000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🧰 Additional context used📓 Path-based instructions (2)@(package.json|pyproject.toml|setup.py|Cargo.toml|go.mod|pom.xml|build.gradle|VERSION)📄 CodeRabbit inference engine (Custom checks)
Files:
**/CHANGELOG.md📄 CodeRabbit inference engine (Custom checks)
Files:
🧠 Learnings (2)📚 Learning: 2026-03-26T16:14:15.754ZApplied to files:
📚 Learning: 2026-03-26T20:05:44.851ZApplied to files:
🔇 Additional comments (6)
📝 Walkthroughfix: suppress zsh NOMATCH errors in completion using NULL_GLOB and scoped noglob Unmatched glob patterns in zsh completion could surface "no matches found" Resolve this by scoping NULL_GLOB and EXTENDED_GLOB to the completion function Changes:
This confines the behavior change to the completion function only, preserving WalkthroughZsh completion now runs Changes
Poem
🚥 Pre-merge checks | ✅ 8✅ Passed checks (8 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
`emulate -L zsh` restored the default NOMATCH=on, which caused `_files` internals and user zstyles (e.g. specs tagged `globbed-files`) to leak `no matches found: *:globbed-files` errors into the user's prompt whenever an unquoted glob in those specs failed to match. Scope NO_NOMATCH to the completion function via the same `emulate -L` call so those errors stay silent without affecting caller options.
Bump crate version to 0.4.1 and document the zsh completion NOMATCH suppression fix in CHANGELOG.md under the new release section.
`emulate -L zsh -o NO_NOMATCH` silenced `no matches found`, but under NO_NOMATCH an unmatched glob survives as a literal: `_files -/` expands `*(/)` in a directory with no subdirectories, and that `*(/)` string then leaks back as the completion candidate — the user ends up with `runner --dir *(/)` typed into the prompt. Switch to `NULL_GLOB`, which drops unmatched globs silently: no error, no literal residue, and real matches still expand normally. Update the registration-script test to assert the new option, and expand the CHANGELOG entry to describe both symptoms the fix now covers.
`runner --dir <TAB>` in a directory with no subdirs was (a) typing a literal `*(-/)` glob qualifier into the prompt and (b) spewing `bad pattern: *(#q-/):globbed-files` on every TAB. Two stacked bugs in the path-hint delegation: - `setopt noglob` (added earlier to keep `*(*)` literal on the ExecutablePath call) disabled globbing function-wide, so zsh's own `_path_files` could not expand `*(-/)` via its internal `tmp1=( $~tmp1 )` — the pattern survived and reached `compadd` as a candidate. Swap the option for a `noglob` precommand modifier on the `_files` call itself: still blocks call-site expansion of `*(*)`, leaves `_path_files`'s internal globbing untouched so `NULL_GLOB` can drop the no-match case cleanly. - `emulate -L zsh` resets to plain-zsh defaults with `EXTENDED_GLOB` off, but `_files` builds `*(#q-/)` qualifiers and uses `(#b)` backreferences throughout. Opt back in with `-o EXTENDED_GLOB` so its `eval` of the pattern spec parses instead of erroring. Pin both with tests so the fragile interaction between the caller's `emulate` scope, `noglob`, and `_files`'s internal globbing can't silently regress again.
b5f42d9 to
33d9338
Compare
Summary
This PR fixes zsh completion errors by disabling the
NOMATCHoption in the completion function. When_filesinternals or user zstyles evaluate glob patterns containing unquoted*, they can raise "no matches found" errors into the user's prompt under zsh's default behavior. This change ensures those errors are suppressed.Key Changes
src/complete/grouped.zshto add-o NO_NOMATCHflag to theemulate -L zshcommand in the_clap_dynamic_completer_{NAME}functionsrc/complete/mod.rsto verify the registration script includes theNO_NOMATCHoptionGroupedZshandEnvCompleterImplementation Details
emulate -L zsh -o NO_NOMATCHcommand ensures that glob pattern matching failures in completion specs (particularly those tagged withglobbed-files) don't leak error messages to the user's prompt-L) ensures these settings don't affect the caller's environmentregistration_script_disables_nomatch()that validates the completion registration script contains the requiredNO_NOMATCHoption, with clear error messaging if the assertion failshttps://claude.ai/code/session_015ddYu2FjjcpfJN93mABaT3