| author | |
| committer | |
| log | afdfbc0367b261ea43d5618027e23022c01e2c93 |
| tree | 69ad57dfa99ccd0043a12c743fc75255bbd22b28 |
| parent | b184ae5ca5d3d3c0a4b9de564a6e30555e596e65 |
2 files changed, 23 insertions(+), 2 deletions(-)
std/zig/parser_test.zig+16| ... | ... | @@ -28,6 +28,12 @@ test "zig fmt: array literal with hint" { |
| 28 | 28 | \\ 5, |
| 29 | 29 | \\ 6, |
| 30 | 30 | \\ 7 }; |
| 31 | \\const a = []u8{ | |
| 32 | \\ 1, 2, | |
| 33 | \\ 3, 4, // | |
| 34 | \\ 5, 6, // | |
| 35 | \\ 7, 8, // | |
| 36 | \\}; | |
| 31 | 37 | , |
| 32 | 38 | \\const a = []u8{ |
| 33 | 39 | \\ 1, 2, // |
| ... | ... | @@ -53,6 +59,16 @@ test "zig fmt: array literal with hint" { |
| 53 | 59 | \\ 5, 6, // |
| 54 | 60 | \\ 7, |
| 55 | 61 | \\}; |
| 62 | \\const a = []u8{ | |
| 63 | \\ 1, | |
| 64 | \\ 2, | |
| 65 | \\ 3, | |
| 66 | \\ 4, | |
| 67 | \\ 5, | |
| 68 | \\ 6, | |
| 69 | \\ 7, | |
| 70 | \\ 8, | |
| 71 | \\}; | |
| 56 | 72 | \\ |
| 57 | 73 | ); |
| 58 | 74 | } |
std/zig/render.zig+7-2| ... | ... | @@ -1583,8 +1583,13 @@ fn renderToken(tree: &ast.Tree, stream: var, token_index: ast.TokenIndex, indent |
| 1583 | 1583 | } |
| 1584 | 1584 | } |
| 1585 | 1585 | |
| 1586 | if (space == Space.IgnoreEmptyComment and mem.trimRight(u8, tree.tokenSlicePtr(next_token), " ").len == 2) { | |
| 1587 | return stream.writeByte(' '); | |
| 1586 | const comment_is_empty = mem.trimRight(u8, tree.tokenSlicePtr(next_token), " ").len == 2; | |
| 1587 | if (comment_is_empty) { | |
| 1588 | switch (space) { | |
| 1589 | Space.IgnoreEmptyComment => return stream.writeByte(' '), | |
| 1590 | Space.Newline => return stream.writeByte('\n'), | |
| 1591 | else => {}, | |
| 1592 | } | |
| 1588 | 1593 | } |
| 1589 | 1594 | |
| 1590 | 1595 | var loc = tree.tokenLocationPtr(token.end, next_token); |