Skip to content

Commit

Permalink
Use range_deletion instead of deletion to avoid duplicate range c…
Browse files Browse the repository at this point in the history
…alculation

Co-authored-by: Micha Reiser <[email protected]>
  • Loading branch information
zanieb and MichaReiser authored May 4, 2023
1 parent 76ff675 commit 4f1f06c
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions crates/ruff/src/rules/pydocstyle/rules/sections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,15 +620,13 @@ fn common_section(
if checker.patch(diagnostic.kind.rule()) {
// Replace the existing indentation with whitespace of the appropriate length.
let content = whitespace::clean(docstring.indentation);
if content.is_empty() {
let start = context.range().start();
diagnostic.set_fix(Edit::deletion(start, start + leading_space.text_len()));
let fix_range = TextRange::at(context.range().start(), leading_space.text_len());

diagnostic.set_fix(if content.is_empty() {
Edit::range_deletion(fix_range)
} else {
diagnostic.set_fix(Edit::range_replacement(
content,
TextRange::at(context.range().start(), leading_space.text_len()),
));
}
Edit::range_replacement(content, fix_range)
});
};
checker.diagnostics.push(diagnostic);
}
Expand Down

0 comments on commit 4f1f06c

Please sign in to comment.