From 7339b9bce74eed2d401f0706e436ddf6ec32489a Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 28 May 2021 14:25:30 -0700 Subject: [PATCH] Bump Tree-sitter Pass ranges to `set_byte_range`, `set_point_range` Co-Authored-By: Nathan Sobo --- Cargo.lock | 2 +- Cargo.toml | 2 +- zed/src/editor/buffer/mod.rs | 13 +++++-------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5387343c44..c5645c6f25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2714,7 +2714,7 @@ dependencies = [ [[package]] name = "tree-sitter" version = "0.19.5" -source = "git+https://github.com/tree-sitter/tree-sitter?rev=97dfee63257b5e92197399b381aa993514640adf#97dfee63257b5e92197399b381aa993514640adf" +source = "git+https://github.com/tree-sitter/tree-sitter?rev=d72771a19f4143530b1cfd23808e344f1276e176#d72771a19f4143530b1cfd23808e344f1276e176" dependencies = [ "cc", "regex", diff --git a/Cargo.toml b/Cargo.toml index 46866e3147..02ae3d61a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["zed", "gpui", "gpui_macros", "fsevent", "scoped_pool"] [patch.crates-io] async-task = { git = "https://github.com/zed-industries/async-task", rev = "341b57d6de98cdfd7b418567b8de2022ca993a6e" } -tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter", rev = "97dfee63257b5e92197399b381aa993514640adf" } +tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter", rev = "d72771a19f4143530b1cfd23808e344f1276e176" } # TODO - Remove when a version is released with this PR: https://github.com/servo/core-foundation-rs/pull/457 cocoa = { git = "https://github.com/servo/core-foundation-rs", rev = "025dcb3c0d1ef01530f57ef65f3b1deb948f5737" } diff --git a/zed/src/editor/buffer/mod.rs b/zed/src/editor/buffer/mod.rs index 1f064a049d..65b8075a35 100644 --- a/zed/src/editor/buffer/mod.rs +++ b/zed/src/editor/buffer/mod.rs @@ -99,8 +99,8 @@ impl DerefMut for QueryCursorHandle { impl Drop for QueryCursorHandle { fn drop(&mut self) { let mut cursor = self.0.take().unwrap(); - cursor.set_byte_range(0, usize::MAX); - cursor.set_point_range(Point::zero().into(), Point::MAX.into()); + cursor.set_byte_range(0..usize::MAX); + cursor.set_point_range(Point::zero().into()..Point::MAX.into()); QUERY_CURSORS.lock().push(cursor) } } @@ -734,7 +734,7 @@ impl Buffer { // Find bracket pairs that *inclusively* contain the given range. let range = range.start.to_offset(self).saturating_sub(1)..range.end.to_offset(self) + 1; let mut cursor = QueryCursorHandle::new(); - let matches = cursor.set_byte_range(range.start, range.end).matches( + let matches = cursor.set_byte_range(range).matches( &lang.brackets_query, tree.root_node(), TextProvider(&self.visible_text), @@ -2142,12 +2142,11 @@ impl Snapshot { pub fn highlighted_text_for_range(&mut self, range: Range) -> HighlightedChunks { let chunks = self.text.chunks_in_range(range.clone()); if let Some((language, tree)) = self.language.as_ref().zip(self.tree.as_ref()) { - let mut captures = self.query_cursor.captures( + let captures = self.query_cursor.set_byte_range(range.clone()).captures( &language.highlight_query, tree.root_node(), TextProvider(&self.text), ); - captures.set_byte_range(range.start, range.end); HighlightedChunks { range, @@ -2360,9 +2359,7 @@ impl<'a> HighlightedChunks<'a> { highlights.next_capture.take(); } } - highlights - .captures - .set_byte_range(self.range.start, self.range.end); + highlights.captures.set_byte_range(self.range.clone()); } }