fix: Map new replacement nodes to their mutable equivalents in SyntaxEditor

This commit is contained in:
Giga Bowser 2024-11-18 18:11:13 -05:00
parent 4c755e62a6
commit e66b4f336d
7 changed files with 22 additions and 20 deletions

View file

@ -155,6 +155,12 @@ pub(super) fn apply_edits(editor: SyntaxEditor) -> SyntaxEdit {
}
};
}
Change::Replace(SyntaxElement::Node(target), Some(SyntaxElement::Node(new_target))) => {
*target = tree_mutator.make_syntax_mut(target);
if new_target.ancestors().any(|node| node == tree_mutator.immutable) {
*new_target = new_target.clone_for_update();
}
}
Change::Replace(target, _) | Change::ReplaceWithMany(target, _) => {
*target = tree_mutator.make_element_mut(target);
}