feat: add word and WORD motions
This commit is contained in:
@@ -404,6 +404,55 @@ end
|
||||
assert!(session.editor().should_quit());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn typed_word_motions_remap_keys_and_keep_insert_typing_in_one_undo_group() {
|
||||
let fixture = Fixture::new();
|
||||
fixture.file("buffer.txt", "foo...bar baz");
|
||||
let mut session = fixture.open(
|
||||
r#"
|
||||
Vamp.configure do |config|
|
||||
config.bind "w", nil
|
||||
config.bind "ctrl+f", config.core.word_next
|
||||
config.bind "ctrl+p", config.core.word_previous
|
||||
config.bind "ctrl+e", config.core.word_end
|
||||
config.bind "ctrl+a", config.core.big_word_next
|
||||
config.bind "ctrl+z", config.core.big_word_previous
|
||||
config.bind "ctrl+t", config.core.big_word_end
|
||||
config.bind "ctrl+b", config.core.word_previous, mode: config.modes.insert
|
||||
end
|
||||
"#,
|
||||
);
|
||||
session.handle(Input::Char('w'));
|
||||
assert_eq!(session.editor().cursor().column, 0);
|
||||
for (key, column) in [
|
||||
('f', 3),
|
||||
('e', 5),
|
||||
('f', 6),
|
||||
('p', 3),
|
||||
('z', 0),
|
||||
('a', 10),
|
||||
('t', 12),
|
||||
('z', 10),
|
||||
('z', 0),
|
||||
] {
|
||||
session.handle(Input::Ctrl(key));
|
||||
assert_eq!(session.editor().cursor().column, column, "{key}");
|
||||
}
|
||||
assert!(!session.editor().dirty());
|
||||
session.handle(Input::Char('i'));
|
||||
for ch in "wbeWBE".chars() {
|
||||
session.handle(Input::Char(ch));
|
||||
}
|
||||
session.handle(Input::Ctrl('b'));
|
||||
assert_eq!(session.editor().cursor().column, 0);
|
||||
session.handle(Input::Char('X'));
|
||||
session.handle(Input::Escape);
|
||||
assert_eq!(session.editor().lines(), &["XwbeWBEfoo...bar baz"]);
|
||||
session.handle(Input::Char('u'));
|
||||
assert_eq!(session.editor().lines(), &["foo...bar baz"]);
|
||||
assert!(!session.editor().dirty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn typed_search_bindings_drive_navigation_and_the_search_prompt_only() {
|
||||
let fixture = Fixture::new();
|
||||
|
||||
Reference in New Issue
Block a user