Apply edits in sorted order (#4762)

This commit is contained in:
Charlie Marsh
2023-05-31 13:26:31 -04:00
committed by GitHub
parent bb4f3dedf4
commit 4bd395a850

View File

@@ -65,7 +65,11 @@ fn apply_fixes<'a>(
continue;
}
for edit in fix.edits() {
for edit in fix
.edits()
.iter()
.sorted_unstable_by_key(|edit| edit.start())
{
// Add all contents from `last_pos` to `fix.location`.
let slice = locator.slice(TextRange::new(last_pos.unwrap_or_default(), edit.start()));
output.push_str(slice);