mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
fix: Map new replacement nodes to their mutable equivalents in SyntaxEditor
This commit is contained in:
parent
4c755e62a6
commit
e66b4f336d
7 changed files with 22 additions and 20 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue