mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
zig fmt: Special case un-indent comma after multiline string in param list
This commit is contained in:
parent
1aacedf6e1
commit
4496a6c9cc
@ -3389,6 +3389,13 @@ test "zig fmt: Indent comma correctly after multiline string literals in arg lis
|
||||
\\ g.GtkMessageType.GTK_MESSAGE_WARNING,
|
||||
\\ null,
|
||||
\\ );
|
||||
\\
|
||||
\\ z.display_message_dialog(*const [323:0]u8,
|
||||
\\ \\Message Text
|
||||
\\ \\------------
|
||||
\\ \\xxxxxxxxxxxx
|
||||
\\ \\xxxxxxxxxxxx
|
||||
\\ , g.GtkMessageType.GTK_MESSAGE_WARNING, null);
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
|
||||
@ -1071,6 +1071,13 @@ fn renderExpression(
|
||||
if (i + 1 < params.len) {
|
||||
const next_node = params[i + 1];
|
||||
try renderExpression(allocator, ais, tree, param_node, Space.None);
|
||||
|
||||
// Unindent the comma for multiline string literals
|
||||
const maybe_multiline_string = param_node.firstToken();
|
||||
const is_multiline_string = tree.token_ids[maybe_multiline_string] == .MultilineStringLiteralLine;
|
||||
if (is_multiline_string) ais.popIndent();
|
||||
defer if (is_multiline_string) ais.pushIndent();
|
||||
|
||||
const comma = tree.nextToken(param_node.lastToken());
|
||||
try renderToken(tree, ais, comma, Space.Newline); // ,
|
||||
try renderExtraNewline(tree, ais, next_node);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user