Skip to content

Commit

Permalink
Apply edits in sorted order (#4762)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh authored May 31, 2023
1 parent bb4f3de commit 4bd395a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/ruff/src/autofix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4bd395a

Please sign in to comment.