feat: add configurable Ctrl+j/k list navigation
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user