fix: too_long_first_doc_paragraph suggests wrongly when first line too long

This commit is contained in:
yanglsh 2025-02-22 19:04:25 +08:00
parent e479a9ff95
commit 2ad3520d51
3 changed files with 21 additions and 1 deletions

View file

@ -51,7 +51,11 @@ pub(super) fn check(
// We make this suggestion only if the first doc line ends with a punctuation
// because it might just need to add an empty line with `///`.
should_suggest_empty_doc = doc.ends_with('.') || doc.ends_with('!') || doc.ends_with('?');
} else if spans.len() == 2 {
// We make this suggestion only if the second doc line is not empty.
should_suggest_empty_doc &= !doc.is_empty();
}
let len = doc.chars().count();
if len >= first_paragraph_len {
break;