From edb1a87e70d46a123b103b9e506bde2b678e2ba5 Mon Sep 17 00:00:00 2001 From: Davis Vaughan Date: Thu, 14 Nov 2024 11:59:08 -0500 Subject: [PATCH] Bump tree-sitter-r (#624) * Bump tree-sitter version to get https://github.com/r-lib/tree-sitter-r/pull/152 * Add indent test * tree-sitter-r PR has been merged --- Cargo.lock | 2 +- crates/ark/Cargo.toml | 2 +- crates/ark/src/lsp/indent.rs | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 547eddf8e..5d5d57f8c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3246,7 +3246,7 @@ checksum = "2545046bd1473dac6c626659cc2567c6c0ff302fc8b84a56c4243378276f7f57" [[package]] name = "tree-sitter-r" version = "1.1.0" -source = "git+https://github.com/r-lib/tree-sitter-r?rev=2097fa502efa21349d26af0ffee55d773015e481#2097fa502efa21349d26af0ffee55d773015e481" +source = "git+https://github.com/r-lib/tree-sitter-r?rev=c094bd57652f8a08edc31d79a31222268fe798ee#c094bd57652f8a08edc31d79a31222268fe798ee" dependencies = [ "cc", "tree-sitter-language", diff --git a/crates/ark/Cargo.toml b/crates/ark/Cargo.toml index 8da63c334..754513a71 100644 --- a/crates/ark/Cargo.toml +++ b/crates/ark/Cargo.toml @@ -47,7 +47,7 @@ stdext = { path = "../stdext" } tokio = { version = "1.26.0", features = ["full"] } tower-lsp = "0.19.0" tree-sitter = "0.23.0" -tree-sitter-r = { git = "https://github.com/r-lib/tree-sitter-r", rev = "2097fa502efa21349d26af0ffee55d773015e481" } +tree-sitter-r = { git = "https://github.com/r-lib/tree-sitter-r", rev = "c094bd57652f8a08edc31d79a31222268fe798ee" } uuid = "1.3.0" url = "2.4.1" walkdir = "2" diff --git a/crates/ark/src/lsp/indent.rs b/crates/ark/src/lsp/indent.rs index 20a829717..aaf97fbaa 100644 --- a/crates/ark/src/lsp/indent.rs +++ b/crates/ark/src/lsp/indent.rs @@ -238,6 +238,22 @@ mod tests { assert_match!(indent_edit(&doc, 2), Err(_)); } + #[test] + fn test_line_indent_leading_whitespace() { + // Indent should be unchanged regardless of how much leading whitespace + // there is before the first newline + // https://github.com/posit-dev/positron/issues/5258 + let text = String::from(" \nx"); + let doc = test_doc(&text); + let edit = indent_edit(&doc, 1).unwrap(); + assert!(edit.is_none()); + + let text = String::from("\r\nx"); + let doc = test_doc(&text); + let edit = indent_edit(&doc, 1).unwrap(); + assert!(edit.is_none()); + } + #[test] fn test_line_indent_chains() { let mut text = String::from("foo +\n bar +\n baz + qux |>\nfoofy()");