fix(completion): correct zsh _arguments syntax for options with short and long forms#22690
Closed
KhanCold wants to merge 3 commits into
Closed
fix(completion): correct zsh _arguments syntax for options with short and long forms#22690KhanCold wants to merge 3 commits into
KhanCold wants to merge 3 commits into
Conversation
Fixes NousResearch#22604. The _render_table_block_for_telegram() function was incorrectly including the first column (row-label) as a bullet item when rendering tables for Telegram output. Changed zip(headers, cells) to zip(headers[1:], cells[1:]) to skip the row-label column, matching the expected Telegram output format.
… and long forms
The zsh completion script used invalid _arguments syntax:
'(-h --help){{-h,--help}}[Show help and exit]'
This caused:
_arguments:comparguments:327: invalid argument: (-h --help){-h,--help}[Show help and exit]
The issue is that () groups in _arguments must contain only single-letter
short options, not long options. The space in (-h --help) makes it invalid.
Fix: Replace all (-X --Y) groups with (-), which means the option can be
used with any other option. The correct format is:
'(-)'{-h,--help}'[Show help and exit]'
This follows Zsh's official completion syntax guidelines and fixes tab
completion for all Zsh users.
Fixes NousResearch#22686
Contributor
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.
Bug Description
The
hermes completion zshcommand generates a Zsh completion script with invalid_argumentssyntax, causing:This breaks tab completion for all Zsh users.
Root Cause
The
_argumentssyntax in the generated script uses groups like(-h --help)which is invalid because:()groups in_argumentsmust contain only single-letter short options (e.g.,-h), not long options (--help)(-h --help)makes it syntactically invalidFix
Replace all instances of
(-X --Y)with(-), which means the option can be used with any other option. The correct format is:Changes
hermes_cli/completion.py: Fixed_argumentssyntax ingenerate_zsh()Testing
This fix ensures that
hermes completion zshgenerates valid Zsh completion syntax that works correctly with tab completion.Related
Fixes #22686