Skip to content

Commit

Permalink
Use replacement instead of insertion and deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Feb 29, 2024
1 parent 3da1f01 commit 16a1b2b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1671,25 +1671,24 @@ fn common_section(
} else {
TextSize::new(0)
};
let del_start = context.end() - del_len;
let deletion = Edit::deletion(del_start, context.end());

let insertion = [Edit::insertion(
let edit = Edit::replacement(
format!(
"{}{}",
line_end.repeat(2 - num_blank_lines),
docstring.indentation
),
context.end() - del_len,
context.end(),
)];
);

let mut diagnostic = Diagnostic::new(
BlankLineAfterLastSection {
name: context.section_name().to_string(),
},
docstring.range(),
);
diagnostic.set_fix(Fix::safe_edits(deletion, insertion));
diagnostic.set_fix(Fix::safe_edit(edit));
checker.diagnostics.push(diagnostic);
}
}
Expand Down

0 comments on commit 16a1b2b

Please sign in to comment.