feat: add readline editing keys to text input#75
Open
ronload wants to merge 2 commits into
Open
Conversation
53b2164 to
0a3ef9d
Compare
Text inputs only handled the basic key set (Backspace/Delete/arrows/ Home/End/Char), so control chords fell through to the Char(c) insert arm and Ctrl+H typed an 'h' instead of deleting. Model each keystroke as an EditAction resolved by resolve_edit_key, matching Ctrl/Alt chords before the insert arm so unmapped chords are swallowed rather than typed. A chord arm fires only when exactly one of Ctrl/Alt is held: AltGr is reported as CONTROL|ALT on international layouts, so it falls through to Char(c) and still types '€' and friends. The shared apply_to_draft choke point routes all four input contexts (insert, search, command palette, prompts) through it at once. Adds Ctrl+A/E/B/F/H/D/W/U/K and Alt+B/F/D, backed by three new draft primitives: delete_word_backward, kill_to_start, kill_to_end. Ctrl+N and Ctrl+P are left unmapped since upstream handlers reserve them for popup and list navigation.
0a3ef9d to
ca7e13e
Compare
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.
Text inputs (the add/edit dialog,
/search, the command palette, and the project/context prompts) only handled the basic key set: Backspace, Delete, arrows, Home/End, and printable characters. Control chords fell through to thecharacter-insert path, so
Ctrl+Htyped anhinstead of deleting, and none of the usual readline editing keys worked.This adds the common readline editing set to every text input, routed through the existing
apply_to_draftchoke point so all four contexts stay in sync.Changes
Ctrl+A/Ctrl+E: move to start / end of lineCtrl+B/Ctrl+F: move one character left / rightAlt+B/Alt+F: move one word left / rightCtrl+H: delete character before the cursor;Ctrl+D: delete character under the cursorCtrl+W: delete the word before the cursor;Alt+D: delete the word after the cursorCtrl+U: delete to start of line;Ctrl+K: delete to end of lineEditActionresolved byresolve_edit_key. Ctrl/Alt chords are matched before the insert arm, so an unmapped chord (e.g.Ctrl+G) is swallowed rather than typed as a literal letter, this is the actual fix for theCtrl+Hbehavior.CONTROL | ALTon international layouts, so it falls through to text insert and still types€and friends.Ctrl+N/Ctrl+Pare deliberately left unmapped: upstream handlers reserve them for popup and list navigation.DraftStateprimitives (delete_word_backward,kill_to_start,kill_to_end) with multibyte char-boundary handling, plus unit and resolver tests.All existing tests pass;
cargo clippy --all-targetsandcargo fmt --checkare clean.