Open WillNilges opened 6 days ago
hi, do you have an example input and output to make sure we're talking about the same thing?
Part of the optional configuration is documented on https://github.com/protocolbuffers/txtpbfmt/blob/master/docs/config.md. You can find the full configuration on Config on https://github.com/protocolbuffers/txtpbfmt/blob/master/parser/parser.go#L24 and addToConfig on https://github.com/protocolbuffers/txtpbfmt/blob/master/parser/parser.go#L357.
It seems we don't currently have a configuration to preserve commas. The recommended way is to do one round of formatting first, which will unconditionally remove all the unnecessary commas, and then do the automated edits you want to do.
It is possible to add a new config to optionally preserve commas, let me know if you're interested in contributing it!
You would need to change consumeOptionalSeparator on https://github.com/protocolbuffers/txtpbfmt/blob/master/parser/parser.go#L542 to store it in the AST.
When I use this library to make a change in the AST, and then write it back to a file, I lose commas . This seems to be a standard part of the library, but I am wondering if there's a way to stop this?