mirror of
https://github.com/ziglang/zig.git
synced 2026-01-29 02:35:28 +00:00
zig fmt: handle empty block with comment inside
This commit is contained in:
parent
7e900d28be
commit
b8d4e05361
@ -1,3 +1,14 @@
|
||||
test "zig fmt: empty block with only comment" {
|
||||
try testCanonical(
|
||||
\\comptime {
|
||||
\\ {
|
||||
\\ // comment
|
||||
\\ }
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: no trailing comma on struct decl" {
|
||||
try testTransform(
|
||||
\\const RoundParam = struct {
|
||||
|
||||
@ -1519,7 +1519,7 @@ fn renderToken(tree: &ast.Tree, stream: var, token_index: ast.TokenIndex, indent
|
||||
|
||||
const after_comment_token = tree.tokens.at(token_index + offset);
|
||||
const next_line_indent = switch (after_comment_token.id) {
|
||||
Token.Id.RParen, Token.Id.RBrace, Token.Id.RBracket => indent,
|
||||
Token.Id.RParen, Token.Id.RBrace, Token.Id.RBracket => indent - indent_delta,
|
||||
else => indent,
|
||||
};
|
||||
try stream.writeByteNTimes(' ', next_line_indent);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user