//! Editing, count, insertion, history and repeat contracts. mod support; use notescraft_vim::Mode; #[test] fn delete_and_change_commands() { support::check( &[ ("|abc", "x", "|bc"), ("a|bc", "x", "a|c"), ("ab|c", "x", "a|b"), ("|abc", "2x", "|c"), ("|abc", "9x", "|"), ("|é猫🙂", "x", "|猫🙂"), ("é|猫🙂", "2x", "|é"), ("|abc", "X", "|abc"), ("a|bc", "X", "|bc"), ("ab|c", "2X", "|c"), ("é猫|🙂", "X", "é|🙂"), ("|", "xX", "|"), ("|one two", "dw", "|two"), ("|one two three", "2dw", "|three"), ("|one two three", "d2w", "|three"), ("|one two three four five", "2d2w", "|five"), ("|one two", "de", "| two"), ("one |two", "db", "|two"), ("a|bc", "dl", "a|c"), ("ab|c", "dh", "a|c"), ("a|bc", "d$", "|a"), ("ab|c", "d0", "|c"), ("|abc\ndef", "dd", "|def"), ("abc\n|def", "dd", "|abc"), ("|a\nb\nc", "2dd", "|c"), ("|é\n猫\n🙂", "d2d", "|🙂"), ("|abc", "dd", "|"), ("|abc", "D", "|"), ("a|bc", "D", "|a"), ("a|bc\ndef", "D", "|a\ndef"), ("|one two", "cwX", "|X two"), ("|one two", "ceX", "|X two"), ("a|bc", "clX", "a|Xc"), ("|abc\ndef", "ccX", "|X\ndef"), ("abc\n|def", "ccX", "abc\n|X"), ("|a\nb\nc", "2ccX", "|X\nc"), ("|abc", "sX", "|Xbc"), ("|abc", "2sX", "|Xc"), ("|abc\ndef", "SX", "|X\ndef"), ("a|bc", "CX", "a|X"), ("|é猫🙂", "c2lα", "|α🙂"), ("|abc", "dx", "|bc"), ("|abc", "100000x", "|"), ], Mode::Normal, ); } #[test] fn insertion_replace_join_and_case_commands() { support::check( &[ ("|abc", "iX", "|Xabc"), ("a|bc", "iXY", "aX|Ybc"), ("|", "iabc", "ab|c"), ("|猫", "ié🙂", "é|🙂猫"), ("|abc", "aX", "a|Xbc"), ("ab|c", "aX", "abc|X"), ("|", "aX", "|X"), ("|abc", "AX", "abc|X"), ("a|bc\ndef", "AX", "abc|X\ndef"), (" ab|c", "IX", " |Xabc"), ("|abc", "oX", "abc\n|X"), ("|abc\ndef", "oX", "abc\n|X\ndef"), ("|abc", "OX", "|X\nabc"), ("abc\n|def", "OX", "abc\n|X\ndef"), ("|abc", "rX", "|Xbc"), ("a|bc", "r猫", "a|猫c"), ("|abc", "2rX", "X|Xc"), ("|abc", "9rX", "|abc"), ("|é猫🙂", "rα", "|α猫🙂"), ("|abc", "RXY", "X|Yc"), ("ab|c", "RXY", "abX|Y"), ("|abc", "RX", "|abc"), ("|abc\ndef", "J", "abc| def"), ("|a\nb\nc", "3J", "a b| c"), ("|é\n猫", "J", "é| 猫"), ("|abc", "J", "|abc"), ("|abc", "~", "A|bc"), ("|aB猫", "2~", "Ab|猫"), ("|éα", "~", "É|α"), ("|one TWO", "gUw", "|ONE TWO"), ("|ONE two", "guw", "|one two"), ("|oNe two", "g~w", "|OnE two"), ("|aBc\ndef", "gUU", "|ABC\ndef"), ("|ABC\ndef", "guu", "|abc\ndef"), ("|aBc\ndef", "g~~", "|AbC\ndef"), ("|abc", "iX", "|abc"), ("|abc", "iXY", "X\n|Yabc"), ("|abc", "i", "|\tabc"), ], Mode::Normal, ); } #[test] fn undo_redo_and_dot_group_changes() { support::check( &[ ("|abc", "xu", "|abc"), ("|abc", "xu", "|bc"), ("|abc", "xxu", "|bc"), ("|abc", "xx2u", "|abc"), ("|abc", "iXYZu", "|abc"), ("|abc", "iXYZu", "XY|Zabc"), ("|one two", "cwXYZu", "|one two"), ("|abc", "RuVu", "|abc"), ("|abc", "u", "|abc"), ("|abc", "x.", "|c"), ("|abcdef", "2x.", "|ef"), ("|one two three", "dw.", "|three"), ("|abc", "rXl.", "X|Xc"), ("|abc", "iXl.", "X|Xabc"), ("|abc", "~.", "AB|c"), ("|abc", "xulx", "a|c"), ("|é猫🙂", "xu", "|猫🙂"), ("|one two three", "cwXw.", "X |X three"), ("|abc", ".", "|abc"), ("|abc", "x2.", "|"), ("|abcd", "x..", "|d"), ], Mode::Normal, ); } #[test] fn unfinished_commands_expose_modes() { support::check(&[("|abc", "i", "|abc"), ("|", "i猫", "猫|")], Mode::Insert); support::check(&[("|abc", "R", "|abc"), ("|abc", "R猫", "猫|bc")], Mode::Replace); support::check(&[("|abc", "v", "|abc"), ("|abc", "vl", "a|bc")], Mode::Visual); support::check(&[("|abc", "V", "|abc"), ("|abc", "VV", "|abc")], Mode::VisualLine); support::check(&[("|abc", ":", "|abc"), ("|abc", "/abc", "|abc")], Mode::CommandLine); }