fix: Skip modifying the root layer range, it always covers 0..max

This commit is contained in:
Blaž Hrastnik 2022-01-08 17:35:32 +09:00
parent 7315f6f3e4
commit 9508684031

View file

@ -494,7 +494,13 @@ impl Syntax {
} }
for layer in &mut self.layers.values_mut() { for layer in &mut self.layers.values_mut() {
// The root layer always covers the whole range (0..usize::MAX)
if layer.depth == 0 {
continue;
}
for range in &mut layer.ranges { for range in &mut layer.ranges {
// Roughly based on https://github.com/tree-sitter/tree-sitter/blob/ddeaa0c7f534268b35b4f6cb39b52df082754413/lib/src/subtree.c#L691-L720
for edit in edits.iter().rev() { for edit in edits.iter().rev() {
let is_pure_insertion = edit.old_end_byte == edit.start_byte; let is_pure_insertion = edit.old_end_byte == edit.start_byte;