Skip to content

fix(zsh): preserve options for default completion#693

Merged
jdx merged 1 commit into
mainfrom
codex/fix-zsh-default-completion
Jun 23, 2026
Merged

fix(zsh): preserve options for default completion#693
jdx merged 1 commit into
mainfrom
codex/fix-zsh-default-completion

Conversation

@jdx

@jdx jdx commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • keep the generated zsh init fallback in a completion-friendly option state after emulate -L zsh
  • disable nomatch and enable extendedglob before delegating to _files
  • extend the zsh init integration test to cover the non-usage fallback path

Fixes #692.

Validation

  • cargo test -p usage-lib test_complete_zsh_init
  • cargo test -p usage-cli test_zsh_completion_init_integration --test shell_completions_integration

Note

Low Risk
Narrow change to generated zsh init completion and its tests; no auth, data, or core runtime behavior.

Overview
The generated zsh completion-init handler (_usage_default_complete) now runs setopt localoptions nonomatch extendedglob immediately after emulate -L zsh, so when a command is not a usage shebang and the handler falls back to _files, file completion still sees nomatch off and extendedglob on instead of whatever emulate left behind.

The zsh init integration test stubs _files to report those options, adds a plain (non-usage) completion case to hit the fallback path, and asserts nomatch=off extendedglob=on. The complete_zsh_init snapshot is updated for the new line in generated output.

Reviewed by Cursor Bugbot for commit 3d9c234. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jdx, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 16 minutes and 45 seconds. Learn how PR review limits work.

To continue reviewing without waiting, enable usage-based billing in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 140a7efd-0a94-4d87-893f-9fcd67c51706

📥 Commits

Reviewing files that changed from the base of the PR and between d5b9cb8 and 3d9c234.

⛔ Files ignored due to path filters (1)
  • lib/src/complete/snapshots/usage__complete__zsh__tests__complete_zsh_init.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • cli/tests/shell_completions_integration.rs
  • lib/src/complete/zsh.rs

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes zsh default completion by ensuring the generated _usage_default_complete function is in a completion-friendly option state when it delegates to _files for non-usage-shebang commands.

  • Inserts setopt localoptions nonomatch extendedglob immediately after emulate -L zsh in the generated shell function, so that glob matching errors are suppressed and extended globs are available when _files runs.
  • Extends the integration test with a plain command (no usage shebang) to drive the _files fallback path and assert the correct option values (nomatch=off extendedglob=on).

Confidence Score: 5/5

Safe to merge — a minimal, targeted fix to the generated zsh completion function with no side effects on the usage-shebang path.

The change is a single-line addition to a shell code template. emulate -L zsh already makes all option changes local, so the localoptions part of the new setopt is redundant but harmless; nonomatch and extendedglob are exactly the options _files needs to work correctly. The integration test directly verifies both option values at the point _files is called, and the snapshot captures the generated output. No existing behaviour on the usage-shebang path is touched.

No files require special attention.

Important Files Changed

Filename Overview
lib/src/complete/zsh.rs Adds setopt localoptions nonomatch extendedglob after emulate -L zsh in the generated _usage_default_complete shell function to ensure _files receives a compatible option state
lib/src/complete/snapshots/usage__complete__zsh__tests__complete_zsh_init.snap Snapshot updated to reflect the new setopt localoptions nonomatch extendedglob line; consistent with the code change
cli/tests/shell_completions_integration.rs Integration test extended with a plain command (non-usage-shebang) to exercise the _files fallback path and assert that nomatch=off and extendedglob=on are in effect when _files is called

Reviews (1): Last reviewed commit: "fix(zsh): preserve options for default c..." | Re-trigger Greptile

@jdx jdx enabled auto-merge (squash) June 23, 2026 18:13
@jdx jdx merged commit 4aa5d56 into main Jun 23, 2026
6 checks passed
@jdx jdx deleted the codex/fix-zsh-default-completion branch June 23, 2026 18:13
@greptile-apps greptile-apps Bot mentioned this pull request Jun 23, 2026
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.

usage g completion-init zsh breaks default completion with _files

1 participant