Repository navigation
Conversation
…n+Backspace macOS terminals send ESC b / ESC f for Option+Left/Right, and many Linux terminals send modified CSI arrows (ESC [ 1;3 D, 1;5 C, ...). Both now move the cursor by whole words, and ESC DEL (Option+Backspace) deletes the previous word. Words are whitespace-delimited and the motion steps over folded pastes and multibyte characters as single units. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
What
Word-wise cursor motion in the linenoise editor used by
ds4-agentand the CLI:ESC b/ESC f, alsoESC B/ESC F): previous / next word.ESC [ 1;3 D/C(Alt),1;4(Alt+Shift),1;5(Ctrl, the word-jump key on most Linux terminals and tmux) and1;9(iTerm Meta), in both CSI and SS3 (ESC O 1;3 D) form.ESC DEL): delete the previous word.Words are whitespace-delimited (
isspace). Motion goes through the existinglinenoiseEditPrevLen/NextLenhelpers, so multibyte UTF-8 characters are never split and a folded multiline paste is stepped over as one unit. Ctrl+W now shares the same word-boundary helper instead of duplicating the loop.Behaviour change worth knowing about: a lone ESC followed by
b,f,B,For DEL is now a command, as in readline, rather than ESC being dropped and the character inserted.Who did what
Most of this was written by DS4 itself (the agent in this repo), working on the original request: the word-motion functions, the CSI/SS3 modifier parsing, the
ESC b/fhandling, and the first version oftests/test_linenoise_wordnav.c.I then had it reviewed, and Claude Sonnet 5.5 made these adjustments on top:
' 'toisspace, and pulled the boundary scan into two shared helpers (linenoiseWordStartBefore/linenoiseWordStartAfter), also used bylinenoiseEditDeletePrevWord.ESC DEL) word deletion.linenoiseEditMovePrevWord/MoveNextWordstatic.ESChandling.ESC B/F,ESC DEL, UTF-8 words, and word motion across a folded multiline paste..gitignoreandmake clean.Testing
make tests/test_linenoise_wordnav && ./tests/test_linenoise_wordnavpasses (driveslinenoiseEditFeedthrough pipes usingLINENOISE_ASSUME_TTY, no terminal needed), andmake ds4-agentbuilds without warnings. The test is also wired intomake test.ds4-agenton macOS: Option+Left/Right jump words.make test(needs a model),make cpu, CUDA. No inference code is touched, so there is no speed or correctness impact on the backends.This touches
linenoise.c, as do #426 and #699, so I'd expect small rebases against those if they land first. I didn't find an existing PR or issue for word navigation.