fix(completion): remove spurious single-quote in zsh loadautofunc detection - #2548
Conversation
…ection The zsh completion template introduced in yargs#2424 included a stray single-quote before ${zsh_eval_context[-1]}, causing the comparison: [[ "'${zsh_eval_context[-1]}" == "loadautofunc" ]] to always evaluate as false (comparing "'loadautofunc" vs "loadautofunc"). This broke the autoloaded-function detection entirely, so completions would never fire on the first Tab when the script is zsh-autoloaded. Remove the spurious quote so the comparison is correct: [[ "${zsh_eval_context[-1]}" == "loadautofunc" ]]
|
Over 120 Pull Requests opened in 3 days. To be clear: is this Pull Request entirely AI/LLM generated? |
|
Fair question, and thanks for asking directly rather than just closing it. Yes — I use an AI coding assistant to find and fix small, self-contained bugs, and I review and test each change locally before opening it (for this one: a RED test reproducing the issue, then the fix, then the full suite). I realize a burst of PRs across many repos reads as noise and adds review load you didn't ask for. If commander/yargs would prefer not to receive AI-assisted contributions, just say the word and I'll close these and stay out of your tracker — no hard feelings either way. |
|
That change got introduced right before release: cbf7788 A lot of discussion in #2424 for something that didn't achieve the goal! 😢 The RED test is not appropriate. It is testing for s specific typo and not testing the functionality. Given the difficulty in testing and a minor change, I think just leave the test out. I'll check this by hand before releasing in any case. |
|
Dropped the test — the PR now contains only the one-line fix removing the spurious single-quote in |
lbesecker195
left a comment
There was a problem hiding this comment.
Verified in lib/completion-templates.ts: the string is a JS template literal, so the leading ' is emitted verbatim into the zsh script and the comparison becomes "'loadautofunc" == "loadautofunc", which never matches. Removing it restores the intended check. LGTM.
Bug
The zsh completion template added in #2424 contains a stray single-quote
'before${zsh_eval_context[-1]}, making the autoloaded-function detection always fail:The double-quoted string
"'${zsh_eval_context[-1]}"evaluates to a string with a literal'prepended to the variable value, so the comparison is'loadautofuncvsloadautofunc— never equal. The entireifbranch that makes zsh autoloaded completions work on first Tab press is unreachable.Fix
Remove the spurious
'so the generated script reads:Verification
The test fails (RED) on the original template and passes (GREEN) after the one-character fix. The full suite (828 tests) continues to pass with no regressions.