zsh: prevent duplicate default REMAINDER spec in generated completions#200
Merged
casperdcl merged 2 commits intoiterative:mainfrom Nov 17, 2025
Merged
zsh: prevent duplicate default REMAINDER spec in generated completions#200casperdcl merged 2 commits intoiterative:mainfrom
casperdcl merged 2 commits intoiterative:mainfrom
Conversation
Contributor
Author
|
Maybe I could even fix #183 with this, Junie AI was helpful. I manually tested it, it works. But carefully review, I have no idea what I am doing here. |
Contributor
Author
|
That "thesis" commit comment was also written by Junie, btw. :-) |
6de320a to
7ac13e3
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #200 +/- ##
=======================================
Coverage 89.18% 89.18%
=======================================
Files 3 3
Lines 370 370
=======================================
Hits 330 330
Misses 40 40 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f0d559b to
a1221bd
Compare
- per-function guard variable `{prefix}_defaults_added`
- only append defaults if `(*)`/`(-)*`/default is missing
a1221bd to
aa67127
Compare
aa67127 to
9b5435f
Compare
Contributor
Author
|
Oops, I hope I didn't kill anything here by force-pushing. |
9b5435f to
171be68
Compare
Collaborator
|
just force-pushed:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #183.
When completing commands with a subparser that uses nargs=REMAINDER, zsh could
emit:
Root cause:
': :{prefix}_commands'and'*::: :->{name}') on every function invocation. It only checked for genericvariadic/remainder tokens (
(*),(-)*) and not whether the exact default entry(
*::: :->{name}) had already been added. Repeated invocations led to duplicatedrest specs and the
_argumentserror above.Fix:
{prefix}_defaults_added, initialized alongside{prefix}_optionsand set to1after the first append. This guarantees that thedefault
'*::: :->{name}'is added at most once per session.variadic/rest token (
(*),(-)*) nor the exact default entry is already present.Impact:
*::: :->…entries and the “doubled rest argument definition”error in zsh, including across multiple invocations and after re-sourcing the file.