mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
Skip partial duplicates when applying multi-edit fixes (#6144)
## Summary Right now, if we have two fixes that have an overlapping edit, but not an _identical_ set of edits, they'll conflict, causing us to do another linter traversal. Here, I've enabled the fixer to support partially overlapping edits, which (as an example) let's us greatly reduce the number of iterations required in the test suite. The most common case here is that in which a bunch of edits need to import some symbol, and then use that symbol, but in different ways. In that case, all edits will have a common fix (to import the symbol), but deviate in some way. With this change, we can do all of those edits in one pass. Note that the simplest way to enable this was to store sorted edits on `Fix`. We don't allow modifying the edits on `Fix` once it's constructed, so this is an easy change, and allows us to avoid a bunch of clones and traversals later on. Closes #5800.
This commit is contained in:
parent
badbfb2d3e
commit
4231ed2fc3
7 changed files with 47 additions and 47 deletions
|
@ -245,8 +245,8 @@ impl Workspace {
|
|||
fix: message.fix.map(|fix| ExpandedFix {
|
||||
message: message.kind.suggestion,
|
||||
edits: fix
|
||||
.into_edits()
|
||||
.into_iter()
|
||||
.edits()
|
||||
.iter()
|
||||
.map(|edit| ExpandedEdit {
|
||||
location: source_code.source_location(edit.start()),
|
||||
end_location: source_code.source_location(edit.end()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue