Closed teohhanhui closed 5 years ago
This is an issue with the underlying parser. Currently there is not a parser (that I can find) that supports comment nodes. if one becomes available then I would happily switch the formatter to use that to preserve the comments.
We should follow this issue then: https://github.com/mulesoft-labs/yaml-ast-parser/issues/27
@JPinkney do you think the parser can be updated to https://github.com/eemeli/yaml?, that's what the issue above leads to, it supports fully comments
Only the formatter needs to be updated to use that parser instead. If we do that then a better formatter can be built ontop of that.
Can you share a link to the formatter?
Hi! we've replaced the formatter with a new one that doesn't strip comments!
@JPinkney I still see comments getting removed, any thoughts?
Which version are you on and can you post an example
@JPinkney I'm on redhat.vscode-yaml@0.1.0
. The comments in YAML get removed when calling Format Document
Is there any particular case that the comment gets removed?
Formatting
# First Comment
hello: world
#Second Comment
cwd: /hello
scripts: #Third Comment
postinstall: test #Fourth Comment
#Fifth comment
doesn't remove any comments for me. Do you have any other YAML related extensions installed?
@JPinkney thanks for helping me out, had another YAML formatter installed. :+1:
No worries! I'm glad to see that we could get the issue resolved :)
If
yaml.format.enable
istrue
, using the "Format Document" function destroys YAML comments.