zig fmt: fix infix operator before multiline string literal
This commit is contained in:
parent
74bdc1d1f8
commit
b0ceea1831
|
@ -1,3 +1,12 @@
|
|||
test "zig fmt: infix operator and then multiline string literal" {
|
||||
try testCanonical(
|
||||
\\const x = "" ++
|
||||
\\ \\ hi
|
||||
\\;
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: C pointers" {
|
||||
try testCanonical(
|
||||
\\const Ptr = [*c]i32;
|
||||
|
|
|
@ -340,7 +340,6 @@ fn renderExpression(
|
|||
ast.Node.Id.InfixOp => {
|
||||
const infix_op_node = @fieldParentPtr(ast.Node.InfixOp, "base", base);
|
||||
|
||||
const op_token = tree.tokens.at(infix_op_node.op_token);
|
||||
const op_space = switch (infix_op_node.op) {
|
||||
ast.Node.InfixOp.Op.Period, ast.Node.InfixOp.Op.ErrorUnion, ast.Node.InfixOp.Op.Range => Space.None,
|
||||
else => Space.Space,
|
||||
|
@ -353,7 +352,9 @@ fn renderExpression(
|
|||
};
|
||||
|
||||
try renderToken(tree, stream, infix_op_node.op_token, indent, start_col, after_op_space);
|
||||
if (after_op_space == Space.Newline) {
|
||||
if (after_op_space == Space.Newline and
|
||||
tree.tokens.at(tree.nextToken(infix_op_node.op_token)).id != Token.Id.MultilineStringLiteralLine)
|
||||
{
|
||||
try stream.writeByteNTimes(' ', indent + indent_delta);
|
||||
start_col.* = indent + indent_delta;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user