mirror of
https://github.com/astral-sh/ruff
synced 2026-01-22 05:51:03 -05:00
@@ -528,12 +528,25 @@ pub fn newline_after_last_paragraph(checker: &mut Checker, docstring: &Docstring
|
||||
);
|
||||
if checker.patch(diagnostic.kind.code()) {
|
||||
// Insert a newline just before the end-quote(s).
|
||||
let num_trailing_quotes = "'''".len();
|
||||
let num_trailing_spaces = last_line
|
||||
.chars()
|
||||
.rev()
|
||||
.skip(num_trailing_quotes)
|
||||
.take_while(|c| c.is_whitespace())
|
||||
.count();
|
||||
let content = format!("\n{}", whitespace::clean(docstring.indentation));
|
||||
diagnostic.amend(Fix::insertion(
|
||||
diagnostic.amend(Fix::replacement(
|
||||
content,
|
||||
Location::new(
|
||||
docstring.expr.end_location.unwrap().row(),
|
||||
docstring.expr.end_location.unwrap().column() - "\"\"\"".len(),
|
||||
docstring.expr.end_location.unwrap().column()
|
||||
- num_trailing_spaces
|
||||
- num_trailing_quotes,
|
||||
),
|
||||
Location::new(
|
||||
docstring.expr.end_location.unwrap().row(),
|
||||
docstring.expr.end_location.unwrap().column() - num_trailing_quotes,
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -19,4 +19,21 @@ expression: diagnostics
|
||||
row: 283
|
||||
column: 16
|
||||
parent: ~
|
||||
- kind:
|
||||
NewLineAfterLastParagraph: ~
|
||||
location:
|
||||
row: 588
|
||||
column: 4
|
||||
end_location:
|
||||
row: 590
|
||||
column: 21
|
||||
fix:
|
||||
content: "\n "
|
||||
location:
|
||||
row: 590
|
||||
column: 16
|
||||
end_location:
|
||||
row: 590
|
||||
column: 18
|
||||
parent: ~
|
||||
|
||||
|
||||
@@ -192,4 +192,14 @@ expression: diagnostics
|
||||
column: 7
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
MultiLineSummarySecondLine: ~
|
||||
location:
|
||||
row: 588
|
||||
column: 4
|
||||
end_location:
|
||||
row: 590
|
||||
column: 21
|
||||
fix: ~
|
||||
parent: ~
|
||||
|
||||
|
||||
Reference in New Issue
Block a user