feat: add configurable Ctrl+j/k list navigation

This commit is contained in:
Valdemar Lorenzen
2026-10-08 14:40:39 +02:00
parent c60e625555
commit 9ba8b38898
7 changed files with 726 additions and 76 deletions
+47
View File
@@ -164,6 +164,53 @@ Vamp.command("healthy") { |editor, args| editor.replace "healthy #{args}" }
}
}
#[test]
fn selection_bindings_remap_palette_navigation_without_changing_editing_bindings() {
let fixture = Fixture::new();
fixture.file("buffer.txt", "one two three\none two three");
let mut session = fixture.open(
r#"
Vamp.configure do |config|
config.bind "ctrl+j", nil, mode: config.modes.selection
config.bind "ctrl+f", config.core.down, mode: config.modes.selection
config.bind "ctrl+b", config.core.up, mode: config.modes.selection
end
"#,
);
session.handle(Input::Down);
session.handle(Input::Ctrl('p'));
for ch in "core.word".chars() {
session.handle(Input::Char(ch));
}
session.handle(Input::Ctrl('j'));
assert_eq!(session.editor().palette().unwrap().selected, 0);
assert_eq!(
session.editor().cursor(),
crate::editor::Cursor { row: 1, column: 0 }
);
session.handle(Input::Ctrl('f'));
assert_eq!(
session.editor().palette().unwrap().entries[1].name,
"core.word_next"
);
assert_eq!(session.editor().palette().unwrap().selected, 1);
session.handle(Input::Ctrl('b'));
assert_eq!(session.editor().palette().unwrap().selected, 0);
session.handle(Input::Ctrl('f'));
session.handle(Input::Enter);
assert!(session.editor().palette().is_none());
assert_eq!(
session.editor().cursor(),
crate::editor::Cursor { row: 1, column: 4 }
);
session.handle(Input::Ctrl('k'));
assert_eq!(session.editor().selection_count(), 2);
assert_eq!(
session.editor().lines(),
&["one two three", "one two three"]
);
}
#[test]
fn configured_picker_presentations_preserve_editing_and_docked_focus() {
let fixture = Fixture::new();