zig fmt: respect extra newline between fn and pub usingnamespace

This commit is contained in:
Andrew Kelley
2021-02-23 23:01:16 -07:00
parent bf642204b3
commit db4c15be50
2 changed files with 18 additions and 12 deletions

View File

@@ -321,7 +321,6 @@ pub const Tree = struct {
while (true) switch (tags[n]) {
.root => return 0,
.@"usingnamespace",
.test_decl,
.@"errdefer",
.@"defer",
@@ -468,6 +467,14 @@ pub const Tree = struct {
return i - end_offset;
},
.@"usingnamespace" => {
const main_token = main_tokens[n];
if (main_token > 0 and token_tags[main_token - 1] == .keyword_pub) {
end_offset += 1;
}
return main_token - end_offset;
},
.async_call_one,
.async_call_one_comma,
.async_call,

View File

@@ -4178,17 +4178,16 @@ test "zig fmt: for loop with ptr payload and index" {
// );
//}
// TODO
//test "zig fmt: respect extra newline between fn and pub usingnamespace" {
// try testCanonical(
// \\fn foo() void {
// \\ bar();
// \\}
// \\
// \\pub usingnamespace baz;
// \\
// );
//}
test "zig fmt: respect extra newline between fn and pub usingnamespace" {
try testCanonical(
\\fn foo() void {
\\ bar();
\\}
\\
\\pub usingnamespace baz;
\\
);
}
// TODO
//test "zig fmt: respect extra newline between switch items" {