Skip to content

feat: add readline editing keys to text input#75

Open
ronload wants to merge 2 commits into
webstonehq:mainfrom
ronload:feature/emacs-editing-keys
Open

feat: add readline editing keys to text input#75
ronload wants to merge 2 commits into
webstonehq:mainfrom
ronload:feature/emacs-editing-keys

Conversation

@ronload

@ronload ronload commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

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 the
character-insert path, so Ctrl+H typed an h instead 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_draft choke point so all four contexts stay in sync.

Changes

  • New keys, available in any text input:
    • Ctrl+A / Ctrl+E: move to start / end of line
    • Ctrl+B / Ctrl+F: move one character left / right
    • Alt+B / Alt+F: move one word left / right
    • Ctrl+H: delete character before the cursor; Ctrl+D: delete character under the cursor
    • Ctrl+W: delete the word before the cursor; Alt+D: delete the word after the cursor
    • Ctrl+U: delete to start of line; Ctrl+K: delete to end of line
  • Model each keystroke as an EditAction resolved by resolve_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 the Ctrl+H behavior.
  • A chord fires only when exactly one of Ctrl/Alt is held. AltGr is reported as CONTROL | ALT on international layouts, so it falls through to text insert and still types and friends.
  • Ctrl+N / Ctrl+P are deliberately left unmapped: upstream handlers reserve them for popup and list navigation.
  • Three new DraftState primitives (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-targets and cargo fmt --check are clean.

Note: I kept this scoped to behavior and left the README keybinding tables out for now, happy to add an Insert mode key table to the "Edit dialog" section in this PR if you'd prefer it bundled. I also intentionally did not enable the kitty keyboard protocol: none of these keys need it, and it would add terminal-capability detection and teardown for no functional gain here. Can revisit separately if a future binding ever needs it.

@ronload ronload changed the title feat: add emacs/readline editing keys to text input feat: add readline editing keys to text input Jun 23, 2026
@ronload ronload force-pushed the feature/emacs-editing-keys branch from 53b2164 to 0a3ef9d Compare June 23, 2026 16:34
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.
@ronload ronload force-pushed the feature/emacs-editing-keys branch from 0a3ef9d to ca7e13e Compare June 27, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant