Skip to content

Commit

Permalink
Fix byte offset errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Apr 23, 2023
1 parent 170914b commit 90fc963
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions crates/ruff/src/rules/pydocstyle/rules/indent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,14 @@ pub fn indent(checker: &mut Checker, docstring: &Docstring) {
let mut diagnostic =
Diagnostic::new(OverIndentation, TextRange::empty(over_indented.start()));
if checker.patch(diagnostic.kind.rule()) {
diagnostic.set_fix(Edit::range_replacement(
whitespace::clean(docstring.indentation),
over_indented,
));
let new_indent = whitespace::clean(docstring.indentation);

let edit = if new_indent.is_empty() {
Edit::range_deletion(over_indented)
} else {
Edit::range_replacement(new_indent, over_indented)
};
diagnostic.set_fix(edit);
}
checker.diagnostics.push(diagnostic);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff/src/rules/pydocstyle/rules/sections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ fn blanks_and_section_underline(
);
if checker.patch(diagnostic.kind.rule()) {
let range =
TextRange::at(context.following_range().start(), blank_lines_end);
TextRange::new(context.following_range().start(), blank_lines_end);
// Delete any blank lines between the header and content.
diagnostic.set_fix(Edit::range_deletion(range));
}
Expand Down

0 comments on commit 90fc963

Please sign in to comment.