Update tree-sitter to 0.24 (#24492)

I didn't update it to 0.25 because its Wasm support seems to be
partially broken due to
https://github.com/tree-sitter/tree-sitter/pull/3938: it didn't
introduce a check that the Wasm module's ABI is new enough to include
supertype info while parsing it, and so in the case where it isn't it
ends up interpreting random bytes as the number of supertypes, causing
out-of-bounds memory accesses.

Closes #24489

Release Notes:

- Fixed a rare crash during syntax highlighting
This commit is contained in:
Liam Murphy 2025-02-11 05:52:27 +11:00 committed by GitHub
parent d9909c691d
commit 72e1947025
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 141 additions and 127 deletions

View file

@ -14,6 +14,7 @@ use std::{
ops::{Deref, DerefMut, Range},
sync::Arc,
};
use streaming_iterator::StreamingIterator;
use sum_tree::{Bias, SeekTarget, SumTree};
use text::{Anchor, BufferSnapshot, OffsetRangeExt, Point, Rope, ToOffset, ToPoint};
use tree_sitter::{Node, Query, QueryCapture, QueryCaptures, QueryCursor, QueryMatches, Tree};
@ -1143,7 +1144,7 @@ impl<'a> SyntaxMapMatches<'a> {
impl<'a> SyntaxMapCapturesLayer<'a> {
fn advance(&mut self) {
self.next_capture = self.captures.next().map(|(mat, ix)| mat.captures[ix]);
self.next_capture = self.captures.next().map(|(mat, ix)| mat.captures[*ix]);
}
fn sort_key(&self) -> (usize, Reverse<usize>, usize) {
@ -1280,7 +1281,8 @@ fn get_injections(
for query_range in changed_ranges {
query_cursor.set_byte_range(query_range.start.saturating_sub(1)..query_range.end + 1);
for mat in query_cursor.matches(&config.query, node, TextProvider(text.as_rope())) {
let mut matches = query_cursor.matches(&config.query, node, TextProvider(text.as_rope()));
while let Some(mat) = matches.next() {
let content_ranges = mat
.nodes_for_capture_index(config.content_capture_ix)
.map(|node| node.range())
@ -1554,7 +1556,8 @@ impl<'a> SyntaxLayer<'a> {
query_cursor.set_byte_range(offset.saturating_sub(1)..offset.saturating_add(1));
let mut smallest_match: Option<(u32, Range<usize>)> = None;
for mat in query_cursor.matches(&config.query, self.node(), text) {
let mut matches = query_cursor.matches(&config.query, self.node(), text);
while let Some(mat) = matches.next() {
for capture in mat.captures {
let Some(override_entry) = config.values.get(&capture.index) else {
continue;