-
Notifications
You must be signed in to change notification settings - Fork 39
zsh: prevent duplicate default REMAINDER spec in generated completions #200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
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. |
|
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:
|
casperdcl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
|
Oops, I hope I didn't kill anything here by force-pushing. |
9b5435f to
171be68
Compare
|
just force-pushed:
|
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.