You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bhollis
changed the title
buf format: Unstable results with
buf format: Unstable results with comment after a value in an array in an option
Jul 10, 2024
Hello, thanks for filing this issue, this has to do with the way the comment is being parsed by the AST. In the first example, where there is no whitespace between the comment and the closing bracket, the comment is being parsed as a leading comment of the closing bracket ], whereas in the second example, the comment is being parsed as a trailing comment of the message literal, {key: "value"}.
syntax = "proto3";
package test;
message FormatTest {
option (foo.bar) = {
array: [
{key: "value"} /* comment */] // comment is considered leading comment of "]"
};
}
syntax = "proto3";
package test;
message FormatTest {
option (foo.bar) = {
array: [
{key: "value"}/* comment */ // comment is considered trailing comment of {key: "value"}
]
};
}
We are currently working on making this output stable, since you are correct, regardless of how the AST parses it, we should provide a consistent behaviour here.
GitHub Repository
https://github.com/StatelyCloud/buf-format-unstable
Commands
buf format -w && cat format_repro.proto
Output
Either:
or
Depending on where the closing
]
was before you ranbuf format
.Expected Output
I expect the formatting to be stable - repeated invocations of
buf format
should produce the same results.Anything else?
This is the smallest repro I could find for this - it requires the comment, the object in the array, etc.
The text was updated successfully, but these errors were encountered: