zig fmt: fix firstToken() for extern fn_protos

This commit is contained in:
Isaac Freund 2021-02-22 23:51:15 +01:00
parent 550688f427
commit 45634851de
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
2 changed files with 24 additions and 23 deletions

View File

@ -366,10 +366,6 @@ pub const Tree = struct {
.@"nosuspend",
.asm_simple,
.@"asm",
.fn_proto_simple,
.fn_proto_multi,
.fn_proto_one,
.fn_proto,
.array_type,
.array_type_sentinel,
.error_value,
@ -449,7 +445,12 @@ pub const Tree = struct {
.error_union,
=> n = datas[n].lhs,
.fn_decl => {
.fn_decl,
.fn_proto_simple,
.fn_proto_multi,
.fn_proto_one,
.fn_proto,
=> {
var i = main_tokens[n]; // fn token
while (i > 0) {
i -= 1;

View File

@ -3727,24 +3727,24 @@ test "zig fmt: Don't add extra newline after if" {
);
}
//test "zig fmt: comments in ternary ifs" {
// try testCanonical(
// \\const x = if (true) {
// \\ 1;
// \\} else if (false)
// \\ // Comment
// \\ 0;
// \\const y = if (true)
// \\ // Comment
// \\ 1
// \\else
// \\ 0;
// \\
// \\pub extern "c" fn printf(format: [*:0]const u8, ...) c_int;
// \\
// );
//}
//
test "zig fmt: comments in ternary ifs" {
try testCanonical(
\\const x = if (true) {
\\ 1;
\\} else if (false)
\\ // Comment
\\ 0;
\\const y = if (true)
\\ // Comment
\\ 1
\\else
\\ 0;
\\
\\pub extern "c" fn printf(format: [*:0]const u8, ...) c_int;
\\
);
}
//test "zig fmt: test comments in field access chain" {
// try testCanonical(
// \\pub const str = struct {