fix(autocomplete): respect cursor position in zsh completion - #205
Open
Tmwakalasya wants to merge 2 commits into
Open
Tmwakalasya wants to merge 2 commits into
Tmwakalasya wants to merge 2 commits into
Conversation
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.
Summary
Zsh completion forwards every word after the executable, including words after the cursor. The backend treats the last supplied argument as the word being completed.
For example, with the cursor immediately after
liinopenai models li --format json, completinglireturns no suggestion because the backend receivesjsonas its current word.Limit the quoted array slice to
CURRENT - 1arguments after the executable. This includes the cursor's word, excludes trailing arguments, and preserves spaces and empty arguments. No backend or generated-code changes are needed.Regression coverage
Add 14 cases using the real rendered Zsh script and the existing Go completion helper, with Zsh's UI functions stubbed:
@,@file://, and@data://prefixes.Assertions check exact NUL-delimited forwarded arguments, suggestions or file-completion dispatch, and exit status. Tests skip when Zsh is unavailable.
Validation
The new mid-line-command regression failed before the fix; end-of-line controls passed. After the fix, all of these passed:
No live API calls were made. A live interactive Tab session, the full mock-server integration suite, and the race-detector suite were not run.