@@ -656,8 +656,10 @@ impl LanguageLayer {
656 let edits = Self::generate_edits(old_source.slice(..), changeset);
656 let edits = Self::generate_edits(old_source.slice(..), changeset);
658 // Notify the tree about all the changes
658 // Notify the tree about all the changes
659− for edit in edits {
659+ for edit in edits.iter().rev() {
660+ // apply the edits in reverse. If we applied them in order then edit 1 would disrupt
661+ // the positioning of edit 2
660− self.tree.as_mut().unwrap().edit(&edit);
662+ self.tree.as_mut().unwrap().edit(edit);
663 self.parse(
665 self.parse(