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 and konstin committed Jun 13, 2023
1 parent 8b6f525 commit df1cc1e
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 df1cc1e

Please sign in to comment.