Repository navigation
fix(zsh): stop the completion-init handler from breaking file completion for other commands - #1493
Conversation
…t file fallback `usage g completion-init zsh` registers a `-default-` handler that ran `emulate -L zsh` before deciding whether the command is a usage script. That reset the options `_main_complete` applies for every completer, so the `_files` fallback for ordinary commands ran with `nullglob` and `rcexpandparam` off. Reset options only on the usage path, which returns before `_files` is reached. Fixes #712 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe zsh completion handler now preserves the completion system’s options when it falls back to ChangesZsh completion fallback
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk remains from the reviewed changes. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
|
|
Instruction countsThe comparison never ran — an earlier step failed.
|
<!-- entire-trail-link-start --> https://entire.io/gh/jdx/usage/trails/33 <!-- entire-trail-link-end --> ### 🚀 Features - **(cli)** publish a usage agent skill with packslip by [@jdx](https://github.com/jdx) in [#1509](#1509) - **(complete)** complete a wrapped command's arguments with its own shell completion via delegate= by [@jdx](https://github.com/jdx) in [#1498](#1498) - **(lib)** add getters that read FlagMeta, CommandMeta and ArgMeta fields wherever they live by [@jdx](https://github.com/jdx) in [#1491](#1491) - **(lib)** export the chosen subcommand to scripts as usage_cmd by [@jdx](https://github.com/jdx) in [#1505](#1505) - **(spec)** let a complete node sit inside the arg it completes by [@jdx](https://github.com/jdx) in [#1496](#1496) - **(spec)** list an arg's possible values from a command with `choices run=` by [@jdx](https://github.com/jdx) in [#1497](#1497) ### 🐛 Bug Fixes - **(bash)** complete `--flag=` values when the cursor sits after `=` by [@jdx](https://github.com/jdx) in [#1499](#1499) - **(cli)** run scripts passed to usage bash through a pipe or process substitution by [@jdx](https://github.com/jdx) in [#1494](#1494) - **(cli)** keep usage explain from running a spec's choices run= commands by [@jdx](https://github.com/jdx) in [#1503](#1503) - **(complete)** read --line=LINE in completion requests from typed completers by [@jdx](https://github.com/jdx) in [#1487](#1487) - **(complete)** show completion parse errors without garbling the prompt by [@jdx](https://github.com/jdx) in [#1495](#1495) - **(derive)** ignore closed pipes instead of panicking in generated parse() by [@jdx](https://github.com/jdx) in [#1484](#1484) - **(derive)** keep generated async dispatch from reserving stack for every command by [@jdx](https://github.com/jdx) in [#1488](#1488) - **(fish)** complete words the user has started quoting by [@jdx](https://github.com/jdx) in [#1500](#1500) - **(lib)** resolve inherited usage aliases after multiline workspace entries by [@jdx](https://github.com/jdx) in [#1507](#1507) - **(lib)** make published usage-rs tests self-contained by [@jdx](https://github.com/jdx) in [#1510](#1510) - **(zsh)** stop the completion-init handler from breaking file completion for other commands by [@jdx](https://github.com/jdx) in [#1493](#1493) ### 📚 Documentation - **(cli)** describe fig output as the legacy Fig format by [@jdx](https://github.com/jdx) in [2a1bef6](2a1bef6) - clarify CLI frameworks and generators on the homepage by [@jdx](https://github.com/jdx) in [#1482](#1482) ### 🛡️ Security - remove Entire trail runners by [@jdx](https://github.com/jdx) in [#1485](#1485) ### 🔍 Other Changes - float jdx tools and aube on latest without a release-age delay by [@jdx](https://github.com/jdx) in [#1486](#1486) - run cargo-semver-checks on every published crate by [@jdx](https://github.com/jdx) in [#1490](#1490) - fail pull requests that grow the usage CLI or a derived CLI by more than 1% by [@jdx](https://github.com/jdx) in [#1492](#1492) - make the binary-size check measure the pull request's own code by [@jdx](https://github.com/jdx) in [#1501](#1501) ### 📦️ Dependency Updates - bump jdx/renovate-config workflows to c736149 by [@jdx](https://github.com/jdx) in [06f2f1b](06f2f1b) - bump jdx/renovate-config workflows to aa49efc by [@jdx](https://github.com/jdx) in [9aaedef](9aaedef) - bump jdx/renovate-config workflows to 5b46432 by [@jdx](https://github.com/jdx) in [36f8681](36f8681) - pin jdx/renovate-config workflows to v1.0.0 by [@jdx](https://github.com/jdx) in [a31ae2f](a31ae2f) - update communique to 1.4.2 in mise.lock by [@jdx](https://github.com/jdx) in [805396f](805396f) - upgrade locked mise tools by [@jdx](https://github.com/jdx) in [d8b761d](d8b761d) - update jdx/packslip action to v1.4.0 by [@jdx](https://github.com/jdx) in [#1508](#1508)
https://entire.io/gh/jdx/usage/trails/42
With
source <(usage g completion-init zsh)in.zshrc, completing a command that is not a usage script falls back to_files. The fallback ran after the handler's ownemulate -L zsh, which replaced the options zsh's completion system sets for every completer._filesgotnullglobandrcexpandparamturned off. #692 papered over the resultingno matches founderror withsetopt nonomatch, and #712 reports what happened next: with the glob error suppressed,_path_filescould offer its own pattern, soemacs --<TAB>inserted a literal*.The handler now leaves options alone until it knows the command is a usage script.
emulate -L zshmoved into that branch, which returns before_filesis reached. Commands that are not usage scripts get_fileswith the same options any other completer sees. Completion for usage scripts is unchanged.Anyone who sources the init script picks this up on the next shell start. Completion files generated by
usage g completion zsh <bin>never call_filesand are unaffected.Validation.
test_zsh_completion_init_integrationnow calls the handler under$_comp_options, the way_main_completedoes, and asserts that the_filesstub seesnullglob,rcexpandparamandextendedglobon. Against the old template it fails withnullglob=off rcexpandparam=off. I couldn't reproduce the literal*in a zpty session on zsh 5.9 with default zstyles, so the test checks the option state that causes the symptom, not the symptom itself.Fixes #712
🤖 Generated with Claude Code
Note
Low Risk
Scoped change to generated zsh init completion script and its integration test; per-bin zsh completions are unchanged.
Overview
Fixes broken file completion for non–usage-shebang commands when
usage g completion-init zshis sourced. The default handler no longer runsemulate -L zshandsetopt nonomatch extendedglobat entry; those resets only run on the branch that completes a usage script, so_fileskeeps the completion system’s options (nullglob,rcexpandparam,extendedglob) and avoids regressions like literal*candidates (#712).test_zsh_completion_init_integrationnow drives the handler through acompletewrapper that applies$_comp_options(like_main_complete) and asserts the_filesstub sees those options enabled.Reviewed by Cursor Bugbot for commit 2f1645d. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit