Files
2026-10-14 15:28:51 -03:00

119 lines
4.1 KiB
Rust
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! Text object, visual selection, indentation and paste contracts.
mod support;
use notescraft_vim::Mode;
#[test]
fn word_paragraph_and_delimited_objects() {
support::check(
&[
("o|ne two", "diw", "| two"),
("one t|wo", "diw", "one| "),
("o|ne two", "daw", "|two"),
("one t|wo", "daw", "on|e"),
("é|é two", "diw", "| two"),
("o|ne,two next", "diW", "| next"),
("o|ne,two next", "daW", "|next"),
("o|ne two", "ciwX<Esc>", "|X two"),
("o|ne two", "cawX<Esc>", "|Xtwo"),
("o|ne two", "gUiw", "|ONE two"),
("O|NE two", "guiw", "|one two"),
("o|Ne two", "g~iw", "|OnE two"),
("|one\ntwo\n\nthree", "dip", "|\nthree"),
("|one\ntwo\n\nthree", "dap", "|three"),
("one\n\n|two\nthree", "dip", "one\n|"),
("(|abc)", "di(", "(|)"),
("(|abc)", "di)", "(|)"),
("(|abc)", "dib", "(|)"),
("x (a|bc) y", "da(", "x | y"),
("x (a|bc) y", "da)", "x | y"),
("x (a|bc) y", "dab", "x | y"),
("[|abc]", "di[", "[|]"),
("x [a|bc] y", "da[", "x | y"),
("{|abc}", "di{", "{|}"),
("{|abc}", "diB", "{|}"),
("x {a|bc} y", "da{", "x | y"),
("x {a|bc} y", "daB", "x | y"),
("\"|abc\"", "di\"", "\"|\""),
("x \"a|bc\" y", "da\"", "x |y"),
("'|abc'", "di'", "'|'"),
("x 'a|bc' y", "da'", "x |y"),
("`|abc`", "di`", "`|`"),
("x `a|bc` y", "da`", "x |y"),
("(é|猫🙂)", "di(", "(|)"),
("[é|猫🙂]", "da[", "|"),
("\"é|猫🙂\"", "ci\"α<Esc>", "\"|α\""),
("(|a(b)c)", "di(", "(|)"),
("(a(|b)c)", "di(", "(a(|)c)"),
("|abc", "di(", "|abc"),
("|abc", "di\"", "|abc"),
],
Mode::Normal,
);
}
#[test]
fn visual_operators_and_indentation() {
support::check(
&[
("|abc", "vd", "|bc"),
("|abc", "vld", "|c"),
("ab|c", "vhd", "|a"),
("|abc", "vlcX<Esc>", "|Xc"),
("|abc", "v<Esc>x", "|bc"),
("|é猫🙂", "vld", "|🙂"),
("|abc\ndef", "Vd", "|def"),
("|a\nb\nc", "Vjd", "|c"),
("|a\nb", "VcX<Esc>", "|X\nb"),
("|aBc", "vl~", "|Abc"),
("|abc", "vlU", "|ABc"),
("|ABC", "vlu", "|abC"),
("o|ne two", "viwd", "| two"),
("(|abc)", "vi(d", "(|)"),
("|abc\ndef", ">>", " |abc\ndef"),
(" |abc\ndef", "<<", "|abc\ndef"),
("|a\nb\nc", "2>>", " |a\n b\nc"),
(" |a\n b\nc", "2<<", "|a\nb\nc"),
("|a\nb\nc", ">j", " |a\n b\nc"),
(" |a\n b\nc", "<j", "|a\nb\nc"),
("|abc", "<<", "|abc"),
(" |abc", "<<", "|abc"),
("\t|abc", "<<", "|abc"),
("|é猫", ">>", " |é猫"),
],
Mode::Normal,
);
}
#[test]
fn yanks_pastes_and_register_prefixes() {
support::check(
&[
("|abc", "ylp", "a|abc"),
("|abc", "ylP", "|aabc"),
("|abc", "2ylp", "aa|bbc"),
("|abc", "yl2p", "aa|abc"),
("|abc\ndef", "yyp", "abc\n|abc\ndef"),
("|abc\ndef", "yyP", "|abc\nabc\ndef"),
("|abc\ndef", "Yp", "abc\n|abc\ndef"),
("|é猫🙂", "ylp", "é|é猫🙂"),
("|abc", "xp", "b|ac"),
("|abc", "xP", "|abc"),
("|one two", "ywp", "oone| ne two"),
("|abc", "\"ayl\"ap", "a|abc"),
("|abc", "\"ayl\"aP", "|aabc"),
("|abc", "\"ax\"aP", "|abc"),
("|abc", "ylx\"0P", "|abc"),
("|abc", "yl\"_xP", "|abc"),
("|abc", "\"_xp", "|bc"),
("|abc", "\"_x\"_p", "|bc"),
("|abc", "p", "|abc"),
("|abc", "P", "|abc"),
("|abc", "vlyp", "aa|bbc"),
("|abc\ndef", "Vyp", "abc\n|abc\ndef"),
("|abc", "\"aylxx\"aP", "|ac"),
],
Mode::Normal,
);
}