Skip to content

feat: honor readline keybindings in the comment composer - #45

Merged
osolmaz merged 4 commits into
mainfrom
feat/composer-readline-keys
Jul 26, 2026
Merged

osolmaz merged 4 commits into
mainfrom
feat/composer-readline-keys

Conversation

@osolmaz

@osolmaz osolmaz commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

The comment composer only understood arrows, Home/End, and Backspace, so shell muscle memory (Ctrl+A, Ctrl+K, Ctrl+W…) hit dead keys.
This change teaches the composer the readline/Emacs chord set that every shell, REPL, and macOS text field honors.
Line motion, word motion, word and line kills with a yank buffer, and delete-under-cursor all work now, with submit (Ctrl+S) and cancel (Ctrl+C/Esc) unchanged.

What Changed

All editing logic lives in the pure composer; the reducer only routes chords, so every behavior is unit-tested without a terminal.

  • Composer ops: kill_to_end (Ctrl+K; at end of line it kills the newline like readline), kill_to_start (Ctrl+U; a no-op at column zero so lines never merge), kill_word_back (Ctrl+W, whitespace-delimited), kill_word_back_alnum (Alt+Backspace, letter/digit boundary), kill_word_forward (Alt+D), word motion (Alt+F/Alt+B, crossing lines), and a single-slot kill buffer yanked by Ctrl+Y.
  • Routing: Ctrl+A/E → line bounds, Ctrl+F/B → char motion, Ctrl+P/N → row motion through wraps, Ctrl+D → delete. Kill/motion chords respect the posting freeze, and Alt chords are explicit exceptions to the guard that ignores stray Alt input; Ctrl+Alt combinations stay inert.
  • README documents the chords; the text-input-keybindings skill in the tools repo is the design source.

Testing

  • cargo fmt --check, check --all-targets, clippy --all-targets --all-features -- -D warnings: clean
  • cargo test: 702 tests pass (~15 new: op boundaries incl. the Ctrl+W vs Alt+Backspace boundary distinction, newline-kill/yank round trips, column-zero guards, freeze interaction, Ctrl+Alt inertness)
  • cargo llvm-cov --fail-under-lines 85 and executing cargo mutants --in-diff run locally; CI runs both again
  • Codex review (gpt-5.6-terra, high): clean on the first pass

Risks

Low — additive bindings on an already-tested editor core; no existing chord changed meaning.

  • The kill buffer is per-draft, not global across composers; consecutive kills replace rather than append (readline appends). Both are deliberate v1 simplifications.

osolmaz added 4 commits July 26, 2026 14:24
Adds the Emacs/readline chord set to the in-app editor: Ctrl+A/E line
bounds, Ctrl+F/B/P/N motion, Alt+F/B word motion, Ctrl+W and
Alt+Backspace word kills with their distinct whitespace vs
letter/digit boundaries, Alt+D forward kill, Ctrl+K/Ctrl+U line kills
(Ctrl+U never merges lines at column zero), Ctrl+D delete, and a
single-slot kill buffer yanked by Ctrl+Y. Kill chords respect the
posting freeze, Alt chords are explicit exceptions to the stray-escape
guard, and Ctrl+S/Ctrl+C keep submit and cancel.
An infinite-loop mutant cannot pass the suite; it hangs and is
detected by the timeout. cargo mutants exits 3 for that case, which
must not fail the gate. Missed mutants (exit 2) still fail.
@osolmaz
osolmaz force-pushed the feat/composer-readline-keys branch from 99c3521 to a14788b Compare July 26, 2026 06:25
@osolmaz
osolmaz merged commit 5c96c8e into main Jul 26, 2026
1 check passed
@osolmaz
osolmaz deleted the feat/composer-readline-keys branch July 26, 2026 06:53
@osolmaz

osolmaz commented Jul 26, 2026

Copy link
Copy Markdown
Owner Author

Final report: merged as 5c96c8e. Full readline tier 1+2 in the composer with a single-slot kill buffer; boundary-heavy tests drove in-diff mutants to 0 missed (6 timeout-only = infinite-loop mutants detected by hanging; the gate now accepts cargo-mutants exit 3 for that case). Codex review clean on the first pass. Deliberate v1 simplifications noted in the body: per-draft kill buffer, replace-not-append kills.

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