fix: route normal-mode cuts through clipboard pipeline
This commit is contained in:
@@ -42,6 +42,72 @@ fn keys(editor: &mut Editor, text: &str) {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn normal_x_cuts_the_hovered_grapheme_for_paste() {
|
||||
for grapheme in ["b", "e\u{301}", "👩🚀"] {
|
||||
let fixture = Fixture::new();
|
||||
let mut editor = fixture.editor(&format!("a{grapheme}z\n"));
|
||||
keys(&mut editor, "lx");
|
||||
assert_eq!(editor.context().text, "az\n");
|
||||
assert_eq!(editor.mode(), Mode::Normal);
|
||||
keys(&mut editor, "P");
|
||||
assert_eq!(editor.context().text, format!("a{grapheme}z\n"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn normal_delete_and_remapped_action_copy_characterwise() {
|
||||
for input in [Input::Delete, Input::Char('q')] {
|
||||
let fixture = Fixture::new();
|
||||
let mut editor = fixture.editor("abz\n");
|
||||
editor
|
||||
.bind("normal", "q", Some("core.delete".into()))
|
||||
.unwrap();
|
||||
keys(&mut editor, "yyl");
|
||||
editor.handle(input);
|
||||
assert_eq!(editor.context().text, "az\n");
|
||||
keys(&mut editor, "uUP");
|
||||
assert_eq!(editor.context().text, "abz\n");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn normal_x_repeat_copies_current_graphemes_and_preserves_empty_line_clipboard() {
|
||||
let fixture = Fixture::new();
|
||||
let mut editor = fixture.editor("abc\n\nxyz\n");
|
||||
keys(&mut editor, "x.");
|
||||
assert_eq!(editor.context().text, "c\n\nxyz\n");
|
||||
keys(&mut editor, "jxjP");
|
||||
assert_eq!(editor.context().text, "c\n\nbxyz\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn normal_x_cuts_at_every_caret_without_crossing_empty_lines() {
|
||||
let fixture = Fixture::new();
|
||||
let source = "a👩🚀z\n\nbe\u{301}y\n";
|
||||
let mut editor = fixture.editor(source);
|
||||
keys(&mut editor, "l");
|
||||
editor.handle(Input::Ctrl('e'));
|
||||
editor.handle(Input::Ctrl('e'));
|
||||
keys(&mut editor, "x");
|
||||
assert_eq!(editor.context().text, "az\n\nby\n");
|
||||
keys(&mut editor, "P");
|
||||
assert_eq!(editor.context().text, source);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insert_delete_and_its_repeat_do_not_overwrite_clipboard() {
|
||||
let fixture = Fixture::new();
|
||||
let mut editor = fixture.editor("abc\nxyz\n");
|
||||
keys(&mut editor, "vyi");
|
||||
editor.handle(Input::Delete);
|
||||
editor.handle(Input::Escape);
|
||||
keys(&mut editor, "j.");
|
||||
assert_eq!(editor.context().text, "bc\nyz\n");
|
||||
keys(&mut editor, "P");
|
||||
assert_eq!(editor.context().text, "bc\nayz\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn visual_r_replaces_selected_graphemes_as_one_undo_edit() {
|
||||
let fixture = Fixture::new();
|
||||
|
||||
Reference in New Issue
Block a user