mirror of
https://github.com/encounter/zed.git
synced 2026-07-11 06:19:04 -07:00
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:
Generated
+106
-103
File diff suppressed because it is too large
Load Diff
+6
-5
@@ -502,6 +502,7 @@ simplelog = "0.12.2"
|
||||
smallvec = { version = "1.6", features = ["union"] }
|
||||
smol = "2.0"
|
||||
sqlformat = "0.2"
|
||||
streaming-iterator = "0.1"
|
||||
strsim = "0.11"
|
||||
strum = { version = "0.26.0", features = ["derive"] }
|
||||
subtle = "2.5.0"
|
||||
@@ -523,7 +524,7 @@ tiny_http = "0.8"
|
||||
toml = "0.8"
|
||||
tokio = { version = "1" }
|
||||
tower-http = "0.4.4"
|
||||
tree-sitter = { version = "0.23", features = ["wasm"] }
|
||||
tree-sitter = { version = "0.24", features = ["wasm"] }
|
||||
tree-sitter-bash = "0.23"
|
||||
tree-sitter-c = "0.23"
|
||||
tree-sitter-cpp = "0.23"
|
||||
@@ -552,16 +553,16 @@ unicode-segmentation = "1.10"
|
||||
unicode-script = "0.5.7"
|
||||
url = "2.2"
|
||||
uuid = { version = "1.1.2", features = ["v4", "v5", "v7", "serde"] }
|
||||
wasmparser = "0.215"
|
||||
wasm-encoder = "0.215"
|
||||
wasmtime = { version = "24", default-features = false, features = [
|
||||
wasmparser = "0.217"
|
||||
wasm-encoder = "0.217"
|
||||
wasmtime = { version = "25", default-features = false, features = [
|
||||
"async",
|
||||
"demangle",
|
||||
"runtime",
|
||||
"cranelift",
|
||||
"component-model",
|
||||
] }
|
||||
wasmtime-wasi = "24"
|
||||
wasmtime-wasi = "25"
|
||||
which = "6.0.0"
|
||||
wit-component = "0.201"
|
||||
zed_llm_client = "0.4"
|
||||
|
||||
@@ -9711,7 +9711,7 @@ async fn test_toggle_block_comment(cx: &mut gpui::TestAppContext) {
|
||||
&r#"
|
||||
<!-- ˇ<script> -->
|
||||
// ˇvar x = new Y();
|
||||
// ˇ</script>
|
||||
<!-- ˇ</script> -->
|
||||
"#
|
||||
.unindent(),
|
||||
);
|
||||
|
||||
@@ -84,7 +84,7 @@ impl HostWorktree for WasmState {
|
||||
latest::HostWorktree::which(self, delegate, binary_name).await
|
||||
}
|
||||
|
||||
fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ impl HostWorktree for WasmState {
|
||||
latest::HostWorktree::which(self, delegate, binary_name).await
|
||||
}
|
||||
|
||||
fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
// We only ever hand out borrows of worktrees.
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ impl HostWorktree for WasmState {
|
||||
latest::HostWorktree::which(self, delegate, binary_name).await
|
||||
}
|
||||
|
||||
fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
// We only ever hand out borrows of worktrees.
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ impl HostKeyValueStore for WasmState {
|
||||
kv_store.insert(key, value).await.to_wasmtime_result()
|
||||
}
|
||||
|
||||
fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> Result<()> {
|
||||
// We only ever hand out borrows of key-value stores.
|
||||
Ok(())
|
||||
}
|
||||
@@ -282,7 +282,7 @@ impl HostWorktree for WasmState {
|
||||
latest::HostWorktree::which(self, delegate, binary_name).await
|
||||
}
|
||||
|
||||
fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
// We only ever hand out borrows of worktrees.
|
||||
Ok(())
|
||||
}
|
||||
@@ -350,7 +350,7 @@ impl http_client::HostHttpResponseStream for WasmState {
|
||||
.to_wasmtime_result()
|
||||
}
|
||||
|
||||
fn drop(&mut self, _resource: Resource<ExtensionHttpResponseStream>) -> Result<()> {
|
||||
async fn drop(&mut self, _resource: Resource<ExtensionHttpResponseStream>) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ impl HostKeyValueStore for WasmState {
|
||||
kv_store.insert(key, value).await.to_wasmtime_result()
|
||||
}
|
||||
|
||||
fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> Result<()> {
|
||||
// We only ever hand out borrows of key-value stores.
|
||||
Ok(())
|
||||
}
|
||||
@@ -275,7 +275,7 @@ impl HostProject for WasmState {
|
||||
Ok(project.worktree_ids())
|
||||
}
|
||||
|
||||
fn drop(&mut self, _project: Resource<Project>) -> Result<()> {
|
||||
async fn drop(&mut self, _project: Resource<Project>) -> Result<()> {
|
||||
// We only ever hand out borrows of projects.
|
||||
Ok(())
|
||||
}
|
||||
@@ -325,7 +325,7 @@ impl HostWorktree for WasmState {
|
||||
Ok(delegate.which(binary_name).await)
|
||||
}
|
||||
|
||||
fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
async fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
|
||||
// We only ever hand out borrows of worktrees.
|
||||
Ok(())
|
||||
}
|
||||
@@ -393,7 +393,7 @@ impl http_client::HostHttpResponseStream for WasmState {
|
||||
.to_wasmtime_result()
|
||||
}
|
||||
|
||||
fn drop(&mut self, _resource: Resource<ExtensionHttpResponseStream>) -> Result<()> {
|
||||
async fn drop(&mut self, _resource: Resource<ExtensionHttpResponseStream>) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ settings.workspace = true
|
||||
similar.workspace = true
|
||||
smallvec.workspace = true
|
||||
smol.workspace = true
|
||||
streaming-iterator.workspace = true
|
||||
strsim.workspace = true
|
||||
sum_tree.workspace = true
|
||||
task.workspace = true
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -15,6 +15,7 @@ doctest = false
|
||||
[dependencies]
|
||||
collections.workspace = true
|
||||
convert_case.workspace = true
|
||||
streaming-iterator.workspace = true
|
||||
tree-sitter-json.workspace = true
|
||||
tree-sitter.workspace = true
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use collections::HashMap;
|
||||
use convert_case::{Case, Casing};
|
||||
use std::{cmp::Reverse, ops::Range, sync::LazyLock};
|
||||
use streaming_iterator::StreamingIterator;
|
||||
use tree_sitter::{Query, QueryMatch};
|
||||
|
||||
fn migrate(text: &str, patterns: MigrationPatterns, query: &Query) -> Option<String> {
|
||||
@@ -11,10 +12,10 @@ fn migrate(text: &str, patterns: MigrationPatterns, query: &Query) -> Option<Str
|
||||
let syntax_tree = parser.parse(&text, None).unwrap();
|
||||
|
||||
let mut cursor = tree_sitter::QueryCursor::new();
|
||||
let matches = cursor.matches(query, syntax_tree.root_node(), text.as_bytes());
|
||||
let mut matches = cursor.matches(query, syntax_tree.root_node(), text.as_bytes());
|
||||
|
||||
let mut edits = vec![];
|
||||
for mat in matches {
|
||||
while let Some(mat) = matches.next() {
|
||||
if let Some((_, callback)) = patterns.get(mat.pattern_index) {
|
||||
edits.extend(callback(&text, &mat, query));
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ serde_json.workspace = true
|
||||
settings.workspace = true
|
||||
sha2.workspace = true
|
||||
smol.workspace = true
|
||||
streaming-iterator.workspace = true
|
||||
theme.workspace = true
|
||||
tree-sitter.workspace = true
|
||||
ui.workspace = true
|
||||
|
||||
@@ -7,6 +7,7 @@ use std::{
|
||||
path::Path,
|
||||
sync::Arc,
|
||||
};
|
||||
use streaming_iterator::StreamingIterator;
|
||||
use tree_sitter::QueryCapture;
|
||||
use util::ResultExt as _;
|
||||
|
||||
@@ -88,7 +89,7 @@ fn syntactic_ranges(
|
||||
let mut ranges = with_query_cursor(|cursor| {
|
||||
cursor
|
||||
.matches(&outline.query, tree.root_node(), text.as_bytes())
|
||||
.filter_map(|mat| {
|
||||
.filter_map_deref(|mat| {
|
||||
mat.captures
|
||||
.iter()
|
||||
.find_map(|QueryCapture { node, index }| {
|
||||
|
||||
@@ -32,6 +32,7 @@ serde_derive.workspace = true
|
||||
serde_json.workspace = true
|
||||
serde_json_lenient.workspace = true
|
||||
smallvec.workspace = true
|
||||
streaming-iterator.workspace = true
|
||||
tree-sitter-json.workspace = true
|
||||
tree-sitter.workspace = true
|
||||
util.workspace = true
|
||||
|
||||
@@ -17,6 +17,7 @@ use std::{
|
||||
str::{self, FromStr},
|
||||
sync::{Arc, LazyLock},
|
||||
};
|
||||
use streaming_iterator::StreamingIterator;
|
||||
use tree_sitter::Query;
|
||||
use util::RangeExt;
|
||||
|
||||
@@ -1262,8 +1263,8 @@ fn replace_value_in_json_text(
|
||||
let mut last_value_range = 0..0;
|
||||
let mut first_key_start = None;
|
||||
let mut existing_value_range = 0..text.len();
|
||||
let matches = cursor.matches(&PAIR_QUERY, syntax_tree.root_node(), text.as_bytes());
|
||||
for mat in matches {
|
||||
let mut matches = cursor.matches(&PAIR_QUERY, syntax_tree.root_node(), text.as_bytes());
|
||||
while let Some(mat) = matches.next() {
|
||||
if mat.captures.len() != 2 {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user