Unnamed repository; edit this file 'description' to name the repository.
syntaxeditor drains wrong side of changed ancestor, making nested edits broken
| -rw-r--r-- | crates/syntax/src/syntax_editor/edit_algo.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/crates/syntax/src/syntax_editor/edit_algo.rs b/crates/syntax/src/syntax_editor/edit_algo.rs index 27ea03ec09..38c786b0f5 100644 --- a/crates/syntax/src/syntax_editor/edit_algo.rs +++ b/crates/syntax/src/syntax_editor/edit_algo.rs @@ -114,6 +114,8 @@ pub(super) fn apply_edits(editor: SyntaxEditor) -> SyntaxEdit { .rev() .position(|ancestor| ancestor.affected_range().contains_range(change.target_range())) { + let index = changed_ancestors.len() - 1 - index; + // Pop off any ancestors that aren't applicable changed_ancestors.drain((index + 1)..); @@ -284,7 +286,7 @@ pub(super) fn apply_edits(editor: SyntaxEditor) -> SyntaxEdit { } } - for DependentChange { parent, child } in dependent_changes.into_iter() { + for DependentChange { parent, child } in dependent_changes.into_iter().rev() { let (input_ancestor, output_ancestor) = match &changes[parent as usize] { // No change will depend on an insert since changes can only depend on nodes in the root tree Change::Insert(_, _) | Change::InsertAll(_, _) => unreachable!(), |