Expand description
Replace-mode binding registration + drift-test helpers.
Audit slice 8.d. The smallest mode in input.rs’s
hand-rolled match table – only four binding shapes:
| Chord | Action |
|---|---|
<Esc> | EnterMode(Normal) |
<BS> | ReplaceUndoLast |
<CR> | Insert("\n") |
| any bare printable | OverwriteChar(c) (wildcard) |
Plus the legacy guard: any modifier-bearing key (<C-x>,
<M-x>, …) returns Action::None. The trie’s
“wildcard only matches bare printable chars” rule
(audit slice 8.b) preserves this for free.
§What this slice ships
register_replace_bindings– the four entries the App’s startup wires into theKeymapHandleunderKeymapLayer::Builtin+BindingMode::Replace.dispatch_replace– the registry-driven dispatcher.KeyEvent → KeyChord → handle.lookup → Action.input::translatecalls this forModalState::Replace; the App constructs a populatedKeymapHandlein [crate::app::App::new] and the runtime threads it throughcrate::input::TranslateContextevery frame.- Drift test in this module’s test block – exhaustive
over the keys Replace mode cares about, asserting that
dispatch_replace(handle, ev) ==the legacytranslate_replace’s reference body for every input. The reference body is kept private to the test module (a literal copy of the pre-migration match table) so a future refactor can’t drift the dispatcher away from the documented Replace-mode semantics. Slice 8.i retires the reference body once every binding routes through a realCommandInvocation.
§Migration template
Subsequent slices (8.e Visual, 8.f Insert, 8.g Normal)
follow the same shape: register_<mode>_bindings,
dispatch_<mode>, and a per-mode drift test against the
legacy translate_<mode> function. Keep the legacy
function private to its test module for the duration of
the migration; drop it in slice 8.i when the merged
catalog covers the whole keystroke surface.
Functions§
- dispatch_
replace - Dispatch a key event through the keymap registry.
- register_
replace_ bindings - Register the four Replace-mode bindings into the supplied
handle’s
Builtinlayer. Called by the App at startup (slice 8.h wires the call site once the App-level keymap boot finalises).