zig fmt: if condition has line break but must not wrap
This commit is contained in:
@@ -1410,31 +1410,31 @@ test "zig fmt: if condition wraps" {
|
||||
\\
|
||||
);
|
||||
}
|
||||
//
|
||||
//test "zig fmt: if condition has line break but must not wrap" {
|
||||
// try testCanonical(
|
||||
// \\comptime {
|
||||
// \\ if (self.user_input_options.put(
|
||||
// \\ name,
|
||||
// \\ UserInputOption{
|
||||
// \\ .name = name,
|
||||
// \\ .used = false,
|
||||
// \\ },
|
||||
// \\ ) catch unreachable) |*prev_value| {
|
||||
// \\ foo();
|
||||
// \\ bar();
|
||||
// \\ }
|
||||
// \\ if (put(
|
||||
// \\ a,
|
||||
// \\ b,
|
||||
// \\ )) {
|
||||
// \\ foo();
|
||||
// \\ }
|
||||
// \\}
|
||||
// \\
|
||||
// );
|
||||
//}
|
||||
//
|
||||
|
||||
test "zig fmt: if condition has line break but must not wrap" {
|
||||
try testCanonical(
|
||||
\\comptime {
|
||||
\\ if (self.user_input_options.put(
|
||||
\\ name,
|
||||
\\ UserInputOption{
|
||||
\\ .name = name,
|
||||
\\ .used = false,
|
||||
\\ },
|
||||
\\ ) catch unreachable) |*prev_value| {
|
||||
\\ foo();
|
||||
\\ bar();
|
||||
\\ }
|
||||
\\ if (put(
|
||||
\\ a,
|
||||
\\ b,
|
||||
\\ )) {
|
||||
\\ foo();
|
||||
\\ }
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
//test "zig fmt: if condition has line break but must not wrap" {
|
||||
// try testCanonical(
|
||||
// \\comptime {
|
||||
|
||||
@@ -1006,13 +1006,11 @@ fn renderWhile(ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Spa
|
||||
break :blk ident + 1;
|
||||
}
|
||||
};
|
||||
const cond_has_newline = !tree.tokensOnSameLine(while_node.ast.while_token, pipe);
|
||||
const brace_space: Space = if (cond_has_newline) .newline else .space;
|
||||
const brace_space: Space = if (ais.isLineOverIndented()) .newline else .space;
|
||||
try renderToken(ais, tree, pipe, brace_space); // |
|
||||
} else {
|
||||
const rparen = tree.lastToken(while_node.ast.cond_expr) + 1;
|
||||
const cond_has_newline = !tree.tokensOnSameLine(while_node.ast.while_token, rparen);
|
||||
const brace_space: Space = if (cond_has_newline) .newline else .space;
|
||||
const brace_space: Space = if (ais.isLineOverIndented()) .newline else .space;
|
||||
try renderToken(ais, tree, rparen, brace_space); // rparen
|
||||
}
|
||||
if (while_node.ast.cont_expr != 0) {
|
||||
|
||||
Reference in New Issue
Block a user