mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-10-15 12:46:50 +00:00
Fix completion after a trailing space in the kitty shell
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) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MA8JGs7pCoXFL2W6jEJ8sD
This commit is contained in:
parent
a54b409785
commit
0791b39abb
2 changed files with 4 additions and 1 deletions
|
|
@ -210,7 +210,7 @@ func SplitForCompletion(s string) (argv []string, position_of_last_arg int) {
|
|||
}
|
||||
if pos < len(s) { // trailing whitespace
|
||||
argv = append(argv, "")
|
||||
position_of_last_arg += len(s) - pos + 1
|
||||
position_of_last_arg = len(s)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -96,6 +96,9 @@ func TestSplitForCompletion(t *testing.T) {
|
|||
test("a b", 2, "a", "b")
|
||||
test("a b ", 4, "a", "b", "")
|
||||
test("a b ", 5, "a", "b", "")
|
||||
test("ab cd ", 6, "ab", "cd", "")
|
||||
test("launch --type ", 14, "launch", "--type", "")
|
||||
test(`a "b c" `, 8, "a", "b c", "")
|
||||
test(`a "b c"`, 2, "a", "b c")
|
||||
test(`a "b c`, 2, "a", "b c")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue