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();
|
||||
|
||||
+24
-2
@@ -6992,7 +6992,7 @@ mod system_clipboard {
|
||||
let revision = editor.text_revision();
|
||||
fixture.fail("fail-write", true);
|
||||
for keys in [
|
||||
"yy", "2y3y", "2dd", "cc", "C", "D", "Y", "s", "d2w", "d2b", "c2w", "c2b",
|
||||
"x", "yy", "2y3y", "2dd", "cc", "C", "D", "Y", "s", "d2w", "d2b", "c2w", "c2b",
|
||||
] {
|
||||
type_text(&mut editor, keys);
|
||||
assert_eq!(editor.context().text, "Xone\ntwo\nthree");
|
||||
@@ -7007,6 +7007,29 @@ mod system_clipboard {
|
||||
assert_eq!(editor.context().text, "XXone\ntXwo\nthree");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn normal_x_publishes_graphemes_and_repeat_failure_is_atomic() {
|
||||
let fixture = Fixture::new();
|
||||
let mut editor = fixture.editor();
|
||||
editor
|
||||
.apply(vec![Effect::Replace("e\u{301}👩🚀z".into())])
|
||||
.unwrap();
|
||||
type_text(&mut editor, "x");
|
||||
assert_eq!(editor.context().text, "👩🚀z");
|
||||
assert_eq!(fixture.bytes("state"), "e\u{301}".as_bytes());
|
||||
fixture.fail("fail-write", true);
|
||||
let before = state(&editor);
|
||||
type_text(&mut editor, ".");
|
||||
assert_eq!(state(&editor), before);
|
||||
assert_eq!(fixture.bytes("state"), "e\u{301}".as_bytes());
|
||||
fixture.fail("fail-write", false);
|
||||
type_text(&mut editor, ".");
|
||||
assert_eq!(editor.context().text, "z");
|
||||
assert_eq!(fixture.bytes("state"), "👩🚀".as_bytes());
|
||||
type_text(&mut editor, "uUP");
|
||||
assert_eq!(editor.context().text, "👩🚀z");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn copy_line_publication_failure_keeps_owned_shape_register_and_full_state() {
|
||||
let fixture = Fixture::new();
|
||||
@@ -7707,7 +7730,6 @@ mod system_clipboard {
|
||||
editor.set_clipboard_mode("system").unwrap();
|
||||
editor.apply(vec![Effect::Replace("plain".into())]).unwrap();
|
||||
set_carets(&mut editor, &[(0, 0)], 0);
|
||||
type_text(&mut editor, "x.");
|
||||
type_text(&mut editor, "iX");
|
||||
editor.handle(Input::Backspace);
|
||||
editor.handle(Input::Delete);
|
||||
|
||||
Reference in New Issue
Block a user