fmt: Skip extra newline if doc_comment exists
This commit is contained in:
@@ -4270,6 +4270,69 @@ test "zig fmt: remove newlines surrounding doc comment" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: remove newlines surrounding doc comment between members" {
|
||||
try testTransform(
|
||||
\\f1: i32,
|
||||
\\
|
||||
\\
|
||||
\\/// doc comment
|
||||
\\
|
||||
\\f2: i32,
|
||||
\\
|
||||
,
|
||||
\\f1: i32,
|
||||
\\
|
||||
\\/// doc comment
|
||||
\\f2: i32,
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: remove newlines surrounding doc comment between members within container decl (1)" {
|
||||
try testTransform(
|
||||
\\const Foo = struct {
|
||||
\\ fn foo() void {}
|
||||
\\
|
||||
\\
|
||||
\\ /// doc comment
|
||||
\\
|
||||
\\
|
||||
\\ fn bar() void {}
|
||||
\\};
|
||||
\\
|
||||
,
|
||||
\\const Foo = struct {
|
||||
\\ fn foo() void {}
|
||||
\\
|
||||
\\ /// doc comment
|
||||
\\ fn bar() void {}
|
||||
\\};
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: remove newlines surrounding doc comment between members within container decl (2)" {
|
||||
try testTransform(
|
||||
\\const Foo = struct {
|
||||
\\ fn foo() void {}
|
||||
\\ /// doc comment 1
|
||||
\\
|
||||
\\ /// doc comment 2
|
||||
\\
|
||||
\\ fn bar() void {}
|
||||
\\};
|
||||
\\
|
||||
,
|
||||
\\const Foo = struct {
|
||||
\\ fn foo() void {}
|
||||
\\ /// doc comment 1
|
||||
\\ /// doc comment 2
|
||||
\\ fn bar() void {}
|
||||
\\};
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: remove newlines surrounding doc comment within container decl" {
|
||||
try testTransform(
|
||||
\\const Foo = struct {
|
||||
|
||||
Reference in New Issue
Block a user