Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/tests/test/commands/movement.rs')
| -rw-r--r-- | helix-term/tests/test/commands/movement.rs | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/helix-term/tests/test/commands/movement.rs b/helix-term/tests/test/commands/movement.rs index 34c9d23b..f263fbac 100644 --- a/helix-term/tests/test/commands/movement.rs +++ b/helix-term/tests/test/commands/movement.rs @@ -450,3 +450,154 @@ async fn test_smart_tab_move_parent_node_end() -> anyhow::Result<()> { Ok(()) } + +#[tokio::test(flavor = "multi_thread")] +async fn select_all_siblings() -> anyhow::Result<()> { + let tests = vec![ + // basic tests + ( + indoc! {r##" + let foo = bar(#[a|]#, b, c); + "##}, + "<A-a>", + indoc! {r##" + let foo = bar(#[a|]#, #(b|)#, #(c|)#); + "##}, + ), + ( + indoc! {r##" + let a = [ + #[1|]#, + 2, + 3, + 4, + 5, + ]; + "##}, + "<A-a>", + indoc! {r##" + let a = [ + #[1|]#, + #(2|)#, + #(3|)#, + #(4|)#, + #(5|)#, + ]; + "##}, + ), + // direction is preserved + ( + indoc! {r##" + let a = [ + #[|1]#, + 2, + 3, + 4, + 5, + ]; + "##}, + "<A-a>", + indoc! {r##" + let a = [ + #[|1]#, + #(|2)#, + #(|3)#, + #(|4)#, + #(|5)#, + ]; + "##}, + ), + // can't pick any more siblings - selection stays the same + ( + indoc! {r##" + let a = [ + #[1|]#, + #(2|)#, + #(3|)#, + #(4|)#, + #(5|)#, + ]; + "##}, + "<A-a>", + indoc! {r##" + let a = [ + #[1|]#, + #(2|)#, + #(3|)#, + #(4|)#, + #(5|)#, + ]; + "##}, + ), + // each cursor does the sibling select independently + ( + indoc! {r##" + let a = [ + #[1|]#, + 2, + 3, + 4, + 5, + ]; + + let b = [ + #("one"|)#, + "two", + "three", + "four", + "five", + ]; + "##}, + "<A-a>", + indoc! {r##" + let a = [ + #[1|]#, + #(2|)#, + #(3|)#, + #(4|)#, + #(5|)#, + ]; + + let b = [ + #("one"|)#, + #("two"|)#, + #("three"|)#, + #("four"|)#, + #("five"|)#, + ]; + "##}, + ), + // conflicting sibling selections get normalized. Here, the primary + // selection would choose every list item, but because the secondary + // range covers more than one item, the descendent is the entire list, + // which means the sibling is the assignment. The list item ranges just + // get normalized out since the list itself becomes selected. + ( + indoc! {r##" + let a = [ + #[1|]#, + 2, + #(3, + 4|)#, + 5, + ]; + "##}, + "<A-a>", + indoc! {r##" + let #(a|)# = #[[ + 1, + 2, + 3, + 4, + 5, + ]|]#; + "##}, + ), + ]; + + for test in tests { + test_with_config(AppBuilder::new().with_file("foo.rs", None), test).await?; + } + + Ok(()) +} |