mirror of
https://github.com/ziglang/zig.git
synced 2026-01-26 09:15:24 +00:00
zig fmt: delete empty comments that do nothing
This commit is contained in:
parent
b184ae5ca5
commit
afdfbc0367
@ -28,6 +28,12 @@ test "zig fmt: array literal with hint" {
|
||||
\\ 5,
|
||||
\\ 6,
|
||||
\\ 7 };
|
||||
\\const a = []u8{
|
||||
\\ 1, 2,
|
||||
\\ 3, 4, //
|
||||
\\ 5, 6, //
|
||||
\\ 7, 8, //
|
||||
\\};
|
||||
,
|
||||
\\const a = []u8{
|
||||
\\ 1, 2, //
|
||||
@ -53,6 +59,16 @@ test "zig fmt: array literal with hint" {
|
||||
\\ 5, 6, //
|
||||
\\ 7,
|
||||
\\};
|
||||
\\const a = []u8{
|
||||
\\ 1,
|
||||
\\ 2,
|
||||
\\ 3,
|
||||
\\ 4,
|
||||
\\ 5,
|
||||
\\ 6,
|
||||
\\ 7,
|
||||
\\ 8,
|
||||
\\};
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
@ -1583,8 +1583,13 @@ fn renderToken(tree: &ast.Tree, stream: var, token_index: ast.TokenIndex, indent
|
||||
}
|
||||
}
|
||||
|
||||
if (space == Space.IgnoreEmptyComment and mem.trimRight(u8, tree.tokenSlicePtr(next_token), " ").len == 2) {
|
||||
return stream.writeByte(' ');
|
||||
const comment_is_empty = mem.trimRight(u8, tree.tokenSlicePtr(next_token), " ").len == 2;
|
||||
if (comment_is_empty) {
|
||||
switch (space) {
|
||||
Space.IgnoreEmptyComment => return stream.writeByte(' '),
|
||||
Space.Newline => return stream.writeByte('\n'),
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
var loc = tree.tokenLocationPtr(token.end, next_token);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user