Bump Tree-sitter

Pass ranges to `set_byte_range`, `set_point_range`

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld 2021-05-28 14:25:30 -07:00
parent 8b7a314474
commit 7339b9bce7
3 changed files with 7 additions and 10 deletions

2
Cargo.lock generated
View File

@ -2714,7 +2714,7 @@ dependencies = [
[[package]] [[package]]
name = "tree-sitter" name = "tree-sitter"
version = "0.19.5" 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 = [ dependencies = [
"cc", "cc",
"regex", "regex",

View File

@ -3,7 +3,7 @@ members = ["zed", "gpui", "gpui_macros", "fsevent", "scoped_pool"]
[patch.crates-io] [patch.crates-io]
async-task = { git = "https://github.com/zed-industries/async-task", rev = "341b57d6de98cdfd7b418567b8de2022ca993a6e" } 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 # 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" } cocoa = { git = "https://github.com/servo/core-foundation-rs", rev = "025dcb3c0d1ef01530f57ef65f3b1deb948f5737" }

View File

@ -99,8 +99,8 @@ impl DerefMut for QueryCursorHandle {
impl Drop for QueryCursorHandle { impl Drop for QueryCursorHandle {
fn drop(&mut self) { fn drop(&mut self) {
let mut cursor = self.0.take().unwrap(); let mut cursor = self.0.take().unwrap();
cursor.set_byte_range(0, usize::MAX); cursor.set_byte_range(0..usize::MAX);
cursor.set_point_range(Point::zero().into(), Point::MAX.into()); cursor.set_point_range(Point::zero().into()..Point::MAX.into());
QUERY_CURSORS.lock().push(cursor) QUERY_CURSORS.lock().push(cursor)
} }
} }
@ -734,7 +734,7 @@ impl Buffer {
// Find bracket pairs that *inclusively* contain the given range. // 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 range = range.start.to_offset(self).saturating_sub(1)..range.end.to_offset(self) + 1;
let mut cursor = QueryCursorHandle::new(); 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, &lang.brackets_query,
tree.root_node(), tree.root_node(),
TextProvider(&self.visible_text), TextProvider(&self.visible_text),
@ -2142,12 +2142,11 @@ impl Snapshot {
pub fn highlighted_text_for_range(&mut self, range: Range<usize>) -> HighlightedChunks { pub fn highlighted_text_for_range(&mut self, range: Range<usize>) -> HighlightedChunks {
let chunks = self.text.chunks_in_range(range.clone()); let chunks = self.text.chunks_in_range(range.clone());
if let Some((language, tree)) = self.language.as_ref().zip(self.tree.as_ref()) { 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, &language.highlight_query,
tree.root_node(), tree.root_node(),
TextProvider(&self.text), TextProvider(&self.text),
); );
captures.set_byte_range(range.start, range.end);
HighlightedChunks { HighlightedChunks {
range, range,
@ -2360,9 +2359,7 @@ impl<'a> HighlightedChunks<'a> {
highlights.next_capture.take(); highlights.next_capture.take();
} }
} }
highlights highlights.captures.set_byte_range(self.range.clone());
.captures
.set_byte_range(self.range.start, self.range.end);
} }
} }