Open schungx opened 1 year ago
Also, some minor annoyances:
some_statement(); // some comment
always gets formatted into either:
some_statement();
// some comment
or
some_statement();// some comment
without at least a space before the //
.
Sometimes it formats nicely:
some_statement(); // some comment
so the pattern is not deterministic.
This is specifically on if
statements, where the space is missing:
if something {// some comments
...
}
And comments within a statement are gone:
let /* comment */ x = 42;
is turned into
let x = 42;
This make formatting a bit troublesome for code with comments that are not line-level (i.e. on their own lines).
In particular, comments at the end of a statement beginning with //
which is quite common.
Fixed, but a minor artifact:
After formatting:
Notice that an extra space is added after let
.
Also, comments following an if
statement is swallowed:
if foo {
bar();
}
// I am an comment
gets formatted to:
if foo {
bar();
}
a = 42; // I am a very very very very very very very very loooooooooooooooooooooooong comment
Very long end-of-line comments move to the line below, which is probably not the intended place:
a = 42;
// I am a very very very very very very very very loooooooooooooooooooooooong comment
In general, end-of-line comments should stay on that same line.
Comments on map properties:
let a = #{
a: 123, // comment for a
b: 234 // comment for b
};
is formatted to:
let a = #{
a: 123,
// comment for a
b:
234 // comment for b
,
};
Format this:
yields this:
The comment on the following line is duplicated.