Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/tests/test/movement.rs')
| -rw-r--r-- | helix-term/tests/test/movement.rs | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/helix-term/tests/test/movement.rs b/helix-term/tests/test/movement.rs index 062d3796..0a17c929 100644 --- a/helix-term/tests/test/movement.rs +++ b/helix-term/tests/test/movement.rs @@ -549,7 +549,69 @@ async fn select_mode_tree_sitter_prev_function_goes_backwards_to_object() -> any } #[tokio::test(flavor = "multi_thread")] +async fn find_char() -> anyhow::Result<()> { + test(("he#[l|]#lo\nhello", "fl", "he#[ll|]#o\nhello")).await?; + test(("hel#[l|]#o\nhello", "fl", "hel#[lo\nhel|]#lo")).await?; + test(("hel#[l|]#o\nhello", "fx", "hel#[l|]#o\nhello")).await?; + test(("he#[l|]#lo\nhello", "2fl", "he#[llo\nhel|]#lo")).await?; + test(("#[h|]#ello\nhello", "9fl", "#[h|]#ello\nhello")).await?; + + test(("h#[e|]#llo\nhello", "tl", "h#[el|]#lo\nhello")).await?; + test(("he#[l|]#lo\nhello", "tl", "he#[llo\nhe|]#llo")).await?; + test(("hel#[l|]#o\nhello", "tl", "hel#[lo\nhe|]#llo")).await?; + test(("hel#[l|]#o\nhello", "tx", "hel#[l|]#o\nhello")).await?; + test(("he#[l|]#lo\nhello", "2tl", "he#[llo\nhel|]#lo")).await?; + test(("#[h|]#ello\nhello", "9tl", "#[h|]#ello\nhello")).await?; + + test(("hello\nhel#[l|]#o", "Fl", "hello\nhe#[|ll]#o")).await?; + test(("hello\nhe#[l|]#lo", "Fl", "hel#[|lo\nhel]#lo")).await?; + test(("hello\n#[h|]#ello", "Fx", "hello\n#[h|]#ello")).await?; + test(("hello\nhel#[l|]#o", "2Fl", "hel#[|lo\nhell]#o")).await?; + test(("hello\nhell#[o|]#", "9Fl", "hello\nhell#[o|]#")).await?; + + test(("hello\nhell#[o|]#", "Tl", "hello\nhel#[|lo]#")).await?; + test(("hello\nhel#[l|]#o", "Tl", "hell#[|o\nhell]#o")).await?; + test(("hello\nhe#[l|]#lo", "Tl", "hell#[|o\nhel]#lo")).await?; + test(("hello\n#[h|]#ello", "Tx", "hello\n#[h|]#ello")).await?; + test(("hello\nhel#[l|]#o", "2Tl", "hel#[|lo\nhell]#o")).await?; + test(("hello\nhell#[o|]#", "9Tl", "hello\nhell#[o|]#")).await?; + + Ok(()) +} + +#[tokio::test(flavor = "multi_thread")] async fn find_char_line_ending() -> anyhow::Result<()> { + test(("on#[e|]#\ntwo\n", "f<ret>", "on#[e\n|]#two\n")).await?; + test(("one#[\n|]#two\n", "f<ret>", "one#[\ntwo\n|]#")).await?; + test(("one\n#[t|]#wo\n", "f<ret>", "one\n#[two\n|]#")).await?; + test(("one#[\n|]#", "f<ret>", "one#[\n|]#")).await?; + test(("#[o|]#ne\ntwo\n", "2f<ret>", "#[one\ntwo\n|]#")).await?; + test(("#[o|]#ne\ntwo\n", "9f<ret>", "#[o|]#ne\ntwo\n")).await?; + + test(("o#[n|]#e\ntwo\n", "t<ret>", "o#[ne|]#\ntwo\n")).await?; + test(("on#[e|]#\ntwo\n", "t<ret>", "on#[e\ntwo|]#\n")).await?; + test(("one#[\n|]#two\n", "t<ret>", "one#[\ntwo|]#\n")).await?; + test(("one#[\n|]#", "t<ret>", "one#[\n|]#")).await?; + test(("on#[e|]#\n", "t<ret>", "on#[e|]#\n")).await?; + test(("#[o|]#ne\ntwo\n", "2t<ret>", "#[one\ntwo|]#\n")).await?; + test(("#[o|]#ne\ntwo\n", "9t<ret>", "#[o|]#ne\ntwo\n")).await?; + + test(("one\ntwo\n#[t|]#hree\n", "F<ret>", "one\ntwo#[|\nt]#hree\n")).await?; + test(("one\ntwo#[\n|]#three\n", "F<ret>", "one#[|\ntwo\n]#three\n")).await?; + test(("one\ntw#[o|]#\nthree\n", "F<ret>", "one#[|\ntwo]#\nthree\n")).await?; + test(("o#[n|]#e\n", "F<ret>", "o#[n|]#e\n")).await?; + test(("#[o|]#ne\n", "F<ret>", "#[o|]#ne\n")).await?; + test(("one\ntwo\nth#[r|]#ee\n", "2F\n", "one#[|\ntwo\nthr]#ee\n")).await?; + test(("one\ntwo\nth#[r|]#ee\n", "9F\n", "one\ntwo\nth#[r|]#ee\n")).await?; + + test(("one\ntwo\nth#[r|]#ee\n", "T<ret>", "one\ntwo\n#[|thr]#ee\n")).await?; + test(("one\ntwo\n#[t|]#hree\n", "T<ret>", "one\n#[|two\nt]#hree\n")).await?; + test(("one\ntwo#[\n|]#three\n", "T<ret>", "one\n#[|two\n]#three\n")).await?; + test(("o#[n|]#e\n", "T<ret>", "o#[n|]#e\n")).await?; + test(("#[o|]#ne\n", "T<ret>", "#[o|]#ne\n")).await?; + test(("one\ntwo\nth#[r|]#ee\n", "2T\n", "one\n#[|two\nthr]#ee\n")).await?; + test(("one\ntwo\nth#[r|]#ee\n", "9T\n", "one\ntwo\nth#[r|]#ee\n")).await?; + test(( indoc! { "\ @@ -588,6 +650,60 @@ async fn find_char_line_ending() -> anyhow::Result<()> { } #[tokio::test(flavor = "multi_thread")] +async fn repeat_find_char() -> anyhow::Result<()> { + test(( + indoc! { + "\ + #[o|]#ne two + one two" + }, + "ft<A-.>", + indoc! { + "\ + one #[two + one t|]#wo" + }, + )) + .await?; + + test(( + indoc! { + "\ + #[o|]#ne two + one two + " + }, + "f<ret><A-.>", + indoc! { + "\ + one two#[ + one two + |]#" + }, + )) + .await?; + + test(( + indoc! { + "\ + #[o|]#ne two + one two + " + }, + "ftf<ret><A-.>", + indoc! { + "\ + one two#[ + one two + |]#" + }, + )) + .await?; + + Ok(()) +} + +#[tokio::test(flavor = "multi_thread")] async fn test_surround_replace() -> anyhow::Result<()> { test(( indoc! {"\ |