refactor(keymap): pass mode arguments in keybindings

Update keybindings for normal, records-normal, editing, and records-editing
modes to pass the appropriate mode names as arguments to the parameterized
commands.

This ensures that the correct mode is entered when using commands like
`edit-or-drill` , `enter-edit-at-cursor` , `commit-cell-edit` , and
`commit-and-advance-right` .

Co-Authored-By: fiddlerwoaroof/git-smart-commit (gemma-4-26B-A4B-it-UD-Q5_K_XL.gguf)
This commit is contained in:
Edward Langley
2026-04-15 22:44:13 -07:00
parent cece34a1d4
commit 30383f203e

View File

@ -431,9 +431,21 @@ impl KeymapSet {
); );
normal.bind(KeyCode::Tab, none, "cycle-panel-focus"); normal.bind(KeyCode::Tab, none, "cycle-panel-focus");
// Editing entry — i/a drill into aggregated cells, else edit // Editing entry — i/a drill into aggregated cells, else edit.
normal.bind(KeyCode::Char('i'), none, "edit-or-drill"); // The mode arg controls which editing mode is entered; records-normal
normal.bind(KeyCode::Char('a'), none, "edit-or-drill"); // overrides these to "records-editing" via its own bindings.
normal.bind_args(
KeyCode::Char('i'),
none,
"edit-or-drill",
vec!["editing".into()],
);
normal.bind_args(
KeyCode::Char('a'),
none,
"edit-or-drill",
vec!["editing".into()],
);
normal.bind(KeyCode::Enter, none, "enter-advance"); normal.bind(KeyCode::Enter, none, "enter-advance");
normal.bind(KeyCode::Char('e'), ctrl, "enter-export-prompt"); normal.bind(KeyCode::Char('e'), ctrl, "enter-export-prompt");
@ -488,10 +500,27 @@ impl KeymapSet {
// ── Records normal mode (inherits from normal) ──────────────────── // ── Records normal mode (inherits from normal) ────────────────────
let mut rn = Keymap::with_parent(normal); let mut rn = Keymap::with_parent(normal);
// Override i/a so the edit branch produces records-editing mode
// instead of inheriting the normal-mode "editing" arg.
rn.bind_args(
KeyCode::Char('i'),
none,
"edit-or-drill",
vec!["records-editing".into()],
);
rn.bind_args(
KeyCode::Char('a'),
none,
"edit-or-drill",
vec!["records-editing".into()],
);
rn.bind_seq( rn.bind_seq(
KeyCode::Char('o'), KeyCode::Char('o'),
none, none,
vec![("add-record-row", vec![]), ("enter-edit-at-cursor", vec![])], vec![
("add-record-row", vec![]),
("enter-edit-at-cursor", vec!["records-editing".into()]),
],
); );
set.insert(ModeKey::RecordsNormal, Arc::new(rn)); set.insert(ModeKey::RecordsNormal, Arc::new(rn));
@ -736,6 +765,8 @@ impl KeymapSet {
set.insert(ModeKey::TileSelect, Arc::new(ts)); set.insert(ModeKey::TileSelect, Arc::new(ts));
// ── Editing mode ───────────────────────────────────────────────── // ── Editing mode ─────────────────────────────────────────────────
// commit-* takes the target edit-mode arg so the command stays
// mode-agnostic; records-editing overrides Enter/Tab below.
let mut ed = Keymap::new(); let mut ed = Keymap::new();
ed.bind_seq( ed.bind_seq(
KeyCode::Esc, KeyCode::Esc,
@ -749,7 +780,7 @@ impl KeymapSet {
KeyCode::Enter, KeyCode::Enter,
none, none,
vec![ vec![
("commit-cell-edit", vec![]), ("commit-cell-edit", vec!["editing".into()]),
("clear-buffer", vec!["edit".into()]), ("clear-buffer", vec!["edit".into()]),
], ],
); );
@ -757,7 +788,7 @@ impl KeymapSet {
KeyCode::Tab, KeyCode::Tab,
none, none,
vec![ vec![
("commit-and-advance-right", vec![]), ("commit-and-advance-right", vec!["editing".into()]),
("clear-buffer", vec!["edit".into()]), ("clear-buffer", vec!["edit".into()]),
], ],
); );
@ -767,6 +798,7 @@ impl KeymapSet {
set.insert(ModeKey::Editing, ed.clone()); set.insert(ModeKey::Editing, ed.clone());
// ── Records editing mode (inherits from editing) ────────────────── // ── Records editing mode (inherits from editing) ──────────────────
// Override Enter/Tab so the post-commit re-enter targets records-editing.
let mut re = Keymap::with_parent(ed); let mut re = Keymap::with_parent(ed);
re.bind_seq( re.bind_seq(
KeyCode::Esc, KeyCode::Esc,
@ -776,6 +808,22 @@ impl KeymapSet {
("enter-mode", vec!["records-normal".into()]), ("enter-mode", vec!["records-normal".into()]),
], ],
); );
re.bind_seq(
KeyCode::Enter,
none,
vec![
("commit-cell-edit", vec!["records-editing".into()]),
("clear-buffer", vec!["edit".into()]),
],
);
re.bind_seq(
KeyCode::Tab,
none,
vec![
("commit-and-advance-right", vec!["records-editing".into()]),
("clear-buffer", vec!["edit".into()]),
],
);
set.insert(ModeKey::RecordsEditing, Arc::new(re)); set.insert(ModeKey::RecordsEditing, Arc::new(re));
// ── Formula edit ───────────────────────────────────────────────── // ── Formula edit ─────────────────────────────────────────────────