mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
fmt: fix first line comment indent in struct init
This commit is contained in:
parent
0563e8e1d4
commit
d645500883
@ -1027,6 +1027,19 @@ test "zig fmt: line comments in struct initializer" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: first line comment in struct initializer" {
|
||||
try testCanonical(
|
||||
\\pub async fn acquire(self: *Self) HeldLock {
|
||||
\\ return HeldLock{
|
||||
\\ // TODO guaranteed allocation elision
|
||||
\\ .held = await (async self.lock.acquire() catch unreachable),
|
||||
\\ .value = &self.private_data,
|
||||
\\ };
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: doc comments before struct field" {
|
||||
try testCanonical(
|
||||
\\pub const Allocator = struct {
|
||||
|
||||
@ -658,11 +658,11 @@ fn renderExpression(
|
||||
return renderToken(tree, stream, suffix_op.rtoken, indent, start_col, space);
|
||||
}
|
||||
|
||||
try renderExpression(allocator, stream, tree, indent, start_col, suffix_op.lhs, Space.None);
|
||||
try renderToken(tree, stream, lbrace, indent, start_col, Space.Newline);
|
||||
|
||||
const new_indent = indent + indent_delta;
|
||||
|
||||
try renderExpression(allocator, stream, tree, new_indent, start_col, suffix_op.lhs, Space.None);
|
||||
try renderToken(tree, stream, lbrace, new_indent, start_col, Space.Newline);
|
||||
|
||||
var it = field_inits.iterator(0);
|
||||
while (it.next()) |field_init| {
|
||||
try stream.writeByteNTimes(' ', new_indent);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user