refactor(command): pre-resolve cell key and grid dimensions in CmdContext

Refactor command system to pre-resolve cell key and grid dimensions
in CmdContext, eliminating repeated GridLayout construction.

Key changes:
- Add cell_key, row_count, col_count to CmdContext
- Replace generic CmdRegistry::register with
  register/register_pure/register_nullary
- Cell commands (clear-cell, yank, paste) now take explicit CellKey
- Update keymap dispatch to use new interactive() method
- Special-case "search" buffer in SetBuffer effect
- Update tests to populate new context fields

This reduces code duplication and makes command execution more
efficient by computing layout once at context creation time.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/Qwen3.5-35B-A3B-GGUF:Q5_K_M)
This commit is contained in:
Edward Langley
2026-04-04 12:14:03 -07:00
parent 649d80cb35
commit 35946afc91
4 changed files with 603 additions and 313 deletions

View File

@ -289,7 +289,12 @@ pub struct SetBuffer {
}
impl Effect for SetBuffer {
fn apply(&self, app: &mut App) {
app.buffers.insert(self.name.clone(), self.value.clone());
// "search" is special — it writes to search_query for backward compat
if self.name == "search" {
app.search_query = self.value.clone();
} else {
app.buffers.insert(self.name.clone(), self.value.clone());
}
}
}