Vscode-yaml: Formatting document should not destroy comments

Created on 19 Mar 2018  路  13Comments  路  Source: redhat-developer/vscode-yaml

If yaml.format.enable is true, using the "Format Document" function destroys YAML comments.

bug formatter

Most helpful comment

Hi! we've replaced the formatter with a new one that doesn't strip comments!

All 13 comments

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.

@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?

The current one? Its just this

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 [email protected] . 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 :)

Was this page helpful?
0 / 5 - 0 ratings