diff --git a/Cargo.lock b/Cargo.lock index 2a6d594f66..0f187a54e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5842,7 +5842,7 @@ dependencies = [ [[package]] name = "tree-sitter" version = "0.20.8" -source = "git+https://github.com/tree-sitter/tree-sitter?rev=477b6677537e89c7bdff14ce84dad6d23a6415bb#477b6677537e89c7bdff14ce84dad6d23a6415bb" +source = "git+https://github.com/tree-sitter/tree-sitter?rev=366210ae925d7ea0891bc7a0c738f60c77c04d7b#366210ae925d7ea0891bc7a0c738f60c77c04d7b" dependencies = [ "cc", "regex", diff --git a/Cargo.toml b/Cargo.toml index b4df3fd101..31a9118a1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ default-members = ["crates/zed"] resolver = "2" [patch.crates-io] -tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter", rev = "477b6677537e89c7bdff14ce84dad6d23a6415bb" } +tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter", rev = "366210ae925d7ea0891bc7a0c738f60c77c04d7b" } async-task = { git = "https://github.com/zed-industries/async-task", rev = "341b57d6de98cdfd7b418567b8de2022ca993a6e" } # TODO - Remove when a version is released with this PR: https://github.com/servo/core-foundation-rs/pull/457 diff --git a/crates/language/src/syntax_map.rs b/crates/language/src/syntax_map.rs index 117699a351..e537e5e793 100644 --- a/crates/language/src/syntax_map.rs +++ b/crates/language/src/syntax_map.rs @@ -284,11 +284,19 @@ impl SyntaxSnapshot { }; layer.tree.edit(&tree_edit); + if edit.new.start.0 < start_byte { break; } } + debug_assert!( + layer.tree.root_node().end_byte() <= text.len(), + "tree's size {}, is larger than text size {}", + layer.tree.root_node().end_byte(), + text.len(), + ); + layers.push(layer, text); cursor.next(text); } diff --git a/crates/text/src/text.rs b/crates/text/src/text.rs index 1f2e4e7c7a..39812740fb 100644 --- a/crates/text/src/text.rs +++ b/crates/text/src/text.rs @@ -2435,7 +2435,7 @@ impl ToOffset for PointUtf16 { impl ToOffset for usize { fn to_offset<'a>(&self, snapshot: &BufferSnapshot) -> usize { - assert!(*self <= snapshot.len(), "offset is out of range"); + assert!(*self <= snapshot.len(), "offset {self} is out of range"); *self } }