Merge pull request #4735 from nfreesto/fmt-fix

Fix for #4585
This commit is contained in:
Folkert de Vries 2022-12-12 19:34:21 +01:00 committed by GitHub
commit c5df39daf4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 10 deletions

View file

@ -556,8 +556,13 @@ pub fn fmt_str_literal<'buf>(buf: &mut Buf<'buf>, literal: StrLiteral, indent: u
for segments in lines.iter() {
for seg in segments.iter() {
buf.indent(indent);
format_str_segment(seg, buf, indent);
// only add indent if the line isn't empty
if *seg != StrSegment::Plaintext("\n") {
buf.indent(indent);
format_str_segment(seg, buf, indent);
} else {
buf.newline();
}
}
buf.newline();

View file

@ -6,7 +6,7 @@ Hello,\n\nWorld!
c =
"""
Hello,
World!
"""