Excessive whitespace trimming with comment formatting (#26455)

Co-authored-by: Erik Johnson <source@ekriirke.net>
This commit is contained in:
Erik Johnson
2026-07-06 11:15:59 +02:00
committed by GitHub
co-authored by Erik Johnson
parent 14a2f67eb4
commit 40a62bc699
3 changed files with 19 additions and 1 deletions
@@ -0,0 +1,9 @@
# Black will inject a space between a comment hash and tab
# as if the tab is non-whitespace.
#Flush
# Normal
# Tabbed
# Double-tabbed
pass # Normal missing pre-hash space
pass # Tabbed, missing pre-hash space
@@ -0,0 +1,9 @@
# Black will inject a space between a comment hash and tab
# as if the tab is non-whitespace.
# Flush
# Normal
# Tabbed
# Double-tabbed
pass # Normal missing pre-hash space
pass # Tabbed, missing pre-hash space
@@ -509,7 +509,7 @@ fn normalize_comment<'a>(
Ok(Cow::Owned(std::format!("# {}", &content["\u{A0}".len()..])))
}
} else {
Ok(Cow::Owned(std::format!("# {}", content.trim_start())))
Ok(Cow::Owned(std::format!("# {content}")))
}
}