aboutsummaryrefslogtreecommitdiff
path: root/helix-term/tests/test/movement.rs
diff options
context:
space:
mode:
authorMichael Davis2024-01-10 19:31:05 +0000
committerBlaž Hrastnik2024-03-23 06:32:34 +0000
commit68b21578ac4b5ded1a262469c6887794a689284f (patch)
treefbffe454d89c9502cd64a714b420b4115294535b /helix-term/tests/test/movement.rs
parentb1222f06640c02feb1b87b988d6bca53fdddb9c0 (diff)
Reimplement tree motions in terms of syntax::TreeCursor
This uses the new TreeCursor type from the parent commit to reimplement the tree-sitter motions (`A-p/o/i/n`). Other tree-sitter related features like textobjects are not touched with this change and will need a different, unrelated approach to solve.
Diffstat (limited to 'helix-term/tests/test/movement.rs')
-rw-r--r--helix-term/tests/test/movement.rs57
1 files changed, 57 insertions, 0 deletions
diff --git a/helix-term/tests/test/movement.rs b/helix-term/tests/test/movement.rs
index 4ebaae85..1c25032c 100644
--- a/helix-term/tests/test/movement.rs
+++ b/helix-term/tests/test/movement.rs
@@ -635,3 +635,60 @@ async fn test_surround_delete() -> anyhow::Result<()> {
Ok(())
}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn tree_sitter_motions_work_across_injections() -> anyhow::Result<()> {
+ test_with_config(
+ AppBuilder::new().with_file("foo.html", None),
+ (
+ "<script>let #[|x]# = 1;</script>",
+ "<A-o>",
+ "<script>let #[|x = 1]#;</script>",
+ ),
+ )
+ .await?;
+
+ // When the full injected layer is selected, expand_selection jumps to
+ // a more shallow layer.
+ test_with_config(
+ AppBuilder::new().with_file("foo.html", None),
+ (
+ "<script>#[|let x = 1;]#</script>",
+ "<A-o>",
+ "#[|<script>let x = 1;</script>]#",
+ ),
+ )
+ .await?;
+
+ test_with_config(
+ AppBuilder::new().with_file("foo.html", None),
+ (
+ "<script>let #[|x = 1]#;</script>",
+ "<A-i>",
+ "<script>let #[|x]# = 1;</script>",
+ ),
+ )
+ .await?;
+
+ test_with_config(
+ AppBuilder::new().with_file("foo.html", None),
+ (
+ "<script>let #[|x]# = 1;</script>",
+ "<A-n>",
+ "<script>let x #[|=]# 1;</script>",
+ ),
+ )
+ .await?;
+
+ test_with_config(
+ AppBuilder::new().with_file("foo.html", None),
+ (
+ "<script>let #[|x]# = 1;</script>",
+ "<A-p>",
+ "<script>#[|let]# x = 1;</script>",
+ ),
+ )
+ .await?;
+
+ Ok(())
+}