aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorMichael Davis2022-09-22 14:49:58 +0000
committerBlaž Hrastnik2022-10-03 14:44:08 +0000
commit6939dd3adb4ccd89ce63e69d9b0586a377a4df42 (patch)
treec51139d1915cb2c0e56e98e685ea0666b6871fa7 /helix-term
parentc253139790034bac62bb51da0efd133d12b7f2c6 (diff)
Add tests for select-mode TS textobjects
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/tests/test/movement.rs128
1 files changed, 128 insertions, 0 deletions
diff --git a/helix-term/tests/test/movement.rs b/helix-term/tests/test/movement.rs
index 088685df..e5abb0b0 100644
--- a/helix-term/tests/test/movement.rs
+++ b/helix-term/tests/test/movement.rs
@@ -85,3 +85,131 @@ async fn cursor_position_newly_opened_file() -> anyhow::Result<()> {
Ok(())
}
+
+#[tokio::test]
+async fn select_mode_tree_sitter_next_function_is_union_of_objects() -> anyhow::Result<()> {
+ test_with_config(
+ Args {
+ files: vec![(PathBuf::from("foo.rs"), Position::default())],
+ ..Default::default()
+ },
+ Config::default(),
+ (
+ helpers::platform_line(indoc! {"\
+ #[/|]#// Increments
+ fn inc(x: usize) -> usize { x + 1 }
+ /// Decrements
+ fn dec(x: usize) -> usize { x - 1 }
+ "})
+ .as_ref(),
+ "]fv]f",
+ helpers::platform_line(indoc! {"\
+ /// Increments
+ #[fn inc(x: usize) -> usize { x + 1 }
+ /// Decrements
+ fn dec(x: usize) -> usize { x - 1 }|]#
+ "})
+ .as_ref(),
+ ),
+ )
+ .await?;
+
+ Ok(())
+}
+
+#[tokio::test]
+async fn select_mode_tree_sitter_prev_function_unselects_object() -> anyhow::Result<()> {
+ test_with_config(
+ Args {
+ files: vec![(PathBuf::from("foo.rs"), Position::default())],
+ ..Default::default()
+ },
+ Config::default(),
+ (
+ helpers::platform_line(indoc! {"\
+ /// Increments
+ #[fn inc(x: usize) -> usize { x + 1 }
+ /// Decrements
+ fn dec(x: usize) -> usize { x - 1 }|]#
+ "})
+ .as_ref(),
+ "v[f",
+ helpers::platform_line(indoc! {"\
+ /// Increments
+ #[fn inc(x: usize) -> usize { x + 1 }|]#
+ /// Decrements
+ fn dec(x: usize) -> usize { x - 1 }
+ "})
+ .as_ref(),
+ ),
+ )
+ .await?;
+
+ Ok(())
+}
+
+#[tokio::test]
+async fn select_mode_tree_sitter_prev_function_goes_backwards_to_object() -> anyhow::Result<()> {
+ // Note: the anchor stays put and the head moves back.
+ test_with_config(
+ Args {
+ files: vec![(PathBuf::from("foo.rs"), Position::default())],
+ ..Default::default()
+ },
+ Config::default(),
+ (
+ helpers::platform_line(indoc! {"\
+ /// Increments
+ fn inc(x: usize) -> usize { x + 1 }
+ /// Decrements
+ fn dec(x: usize) -> usize { x - 1 }
+ /// Identity
+ #[fn ident(x: usize) -> usize { x }|]#
+ "})
+ .as_ref(),
+ "v[f",
+ helpers::platform_line(indoc! {"\
+ /// Increments
+ fn inc(x: usize) -> usize { x + 1 }
+ /// Decrements
+ #[|fn dec(x: usize) -> usize { x - 1 }
+ /// Identity
+ ]#fn ident(x: usize) -> usize { x }
+ "})
+ .as_ref(),
+ ),
+ )
+ .await?;
+
+ test_with_config(
+ Args {
+ files: vec![(PathBuf::from("foo.rs"), Position::default())],
+ ..Default::default()
+ },
+ Config::default(),
+ (
+ helpers::platform_line(indoc! {"\
+ /// Increments
+ fn inc(x: usize) -> usize { x + 1 }
+ /// Decrements
+ fn dec(x: usize) -> usize { x - 1 }
+ /// Identity
+ #[fn ident(x: usize) -> usize { x }|]#
+ "})
+ .as_ref(),
+ "v[f[f",
+ helpers::platform_line(indoc! {"\
+ /// Increments
+ #[|fn inc(x: usize) -> usize { x + 1 }
+ /// Decrements
+ fn dec(x: usize) -> usize { x - 1 }
+ /// Identity
+ ]#fn ident(x: usize) -> usize { x }
+ "})
+ .as_ref(),
+ ),
+ )
+ .await?;
+
+ Ok(())
+}