Repository navigation
Go shlex: fix completion position after trailing space and keep empty quoted strings - #10469
Merged
kovidgoyal merged 2 commits intoSep 15, 2026
Merged
Conversation
SplitForCompletion computed the position of the new empty word as if the previous word were one byte long, so tab completing after a space following a multi-character word replaced part of that word. For example, completing "launch --type " in the kitten @ shell produced "launch --window ". The new word starts at the end of the input. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MA8JGs7pCoXFL2W6jEJ8sD
Port the fix from 2093fb1 in the C shlex implementation to the Go one. Previously an argument such as "" or '' was silently dropped, since an empty word was also used to signal EOF. So "launch --title '' vim" in the kitty shell was parsed as "launch --title vim". EOF is now signalled with a negative Pos. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MA8JGs7pCoXFL2W6jEJ8sD
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.
Two small fixes to the Go shlex package (
tools/utils/shlex), in separate commits.1. Tab completion after a space mangles the previous word in the kitty shell
SplitForCompletionworked out where the new empty word starts as if the word before it were one byte long. The readline completer then cutsbefore_cursorat that position, so part of the previous word gets replaced. To reproduce, runkitten @and typelaunch --type, then press Tab twice:launch --windowlaunch --type windowThe new word always starts at the end of the input, so the fix sets the position to
len(s).2. Empty quoted strings are dropped
The Go lexer used an empty
Valueto mean EOF, so""and''never came out as arguments.launch --title '' vimsplit as["launch", "--title", "vim"]. The C implementation already handles this (2093fb1). This commit ports that fix,allow_emptyincluded, and signals EOF withPos == -1. The empty-string test cases fromkitty_tests/datatypes.pyare now in the Go tests too.Fix 1 has to land before fix 2. Otherwise
a ''would put the completion position past the end of the input.Tests: added cases to
shlex_test.go, and both commits' new tests fail on the code before them../test.pypasses on macOS (707 tests), andgo vetis clean on the affected packages. I also checked the completion fix by hand in a locally built kitty.I used Claude Code for this. I reviewed and tested the changes myself.
🤖 Generated with Claude Code
https://claude.ai/code/session_01MA8JGs7pCoXFL2W6jEJ8sD