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!
"""

View file

@ -574,7 +574,7 @@ formatHelpHelp = \n, cmdHelp ->
"\n\n"
"""
\(indented)COMMANDS:
\(fmtCmdHelp)
"""
@ -606,7 +606,7 @@ formatHelpHelp = \n, cmdHelp ->
|> Str.joinWith "\n"
"""
\(indented)OPTIONS:
\(helpStr)
"""
@ -621,7 +621,7 @@ formatHelpHelp = \n, cmdHelp ->
|> Str.joinWith "\n"
"""
\(indented)ARGS:
\(helpStr)
"""
@ -909,7 +909,7 @@ expect
==
"""
test
OPTIONS:
--foo the foo option (string)
--bar, -B (string)
@ -936,13 +936,13 @@ expect
==
"""
test
COMMANDS:
login
OPTIONS:
--user (string)
--pw (string)
publish
OPTIONS:
--file (string)
@ -960,7 +960,7 @@ expect
"""
test
a test cli app
COMMANDS:
login
"""