space commands here we go again

This commit is contained in:
Priec
2025-09-11 22:36:40 +02:00
parent a604d62d44
commit 0d80266e9b
11 changed files with 331 additions and 141 deletions

View File

@@ -0,0 +1,39 @@
use client::config::binds::config::Config;
use client::input::engine::{InputEngine, InputContext, InputOutcome};
use client::modes::handlers::mode_manager::AppMode;
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
fn ctx() -> InputContext {
InputContext {
app_mode: AppMode::General,
overlay_active: false,
allow_navigation_capture: true,
}
}
fn key(c: char) -> KeyEvent {
KeyEvent::new(KeyCode::Char(c), KeyModifiers::empty())
}
#[test]
fn engine_collects_space_b_r() {
let toml_str = r#"
[keybindings]
revert = ["space+b+r"]
"#;
let config: Config = toml::from_str(toml_str).unwrap();
let mut eng = InputEngine::new(400, 5_000);
// space -> Pending (leader started)
let out1 = eng.process_key(key(' '), &ctx(), &config);
assert!(matches!(out1, InputOutcome::Pending));
// b -> Pending (prefix)
let out2 = eng.process_key(key('b'), &ctx(), &config);
assert!(matches!(out2, InputOutcome::Pending));
// r -> Action(revert)
let out3 = eng.process_key(key('r'), &ctx(), &config);
assert!(matches!(out3, InputOutcome::Action(_)));
}