Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting document should not destroy comments #75

Closed
teohhanhui opened this issue Mar 19, 2018 · 13 comments
Closed

Formatting document should not destroy comments #75

teohhanhui opened this issue Mar 19, 2018 · 13 comments

Comments

@teohhanhui
Copy link

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

@JPinkney
Copy link
Contributor

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.

@teohhanhui
Copy link
Author

We should follow this issue then: mulesoft-labs/yaml-ast-parser#27

@caub
Copy link

caub commented May 31, 2018

@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

@JPinkney
Copy link
Contributor

JPinkney commented Jun 4, 2018

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.

@GuidoS
Copy link

GuidoS commented Jun 5, 2018

Can you share a link to the formatter?

@JPinkney
Copy link
Contributor

JPinkney commented Jun 5, 2018

The current one? Its just this

@JPinkney
Copy link
Contributor

JPinkney commented Oct 1, 2018

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

@JPinkney JPinkney closed this as completed Oct 1, 2018
@frezbo
Copy link

frezbo commented Nov 9, 2018

@JPinkney I still see comments getting removed, any thoughts?

@JPinkney
Copy link
Contributor

JPinkney commented Nov 9, 2018

Which version are you on and can you post an example

@frezbo
Copy link

frezbo commented Nov 9, 2018

@JPinkney I'm on [email protected] . The comments in YAML get removed when calling Format Document

@JPinkney
Copy link
Contributor

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?

@frezbo
Copy link

frezbo commented Nov 10, 2018

@JPinkney thanks for helping me out, had another YAML formatter installed. 👍

@JPinkney
Copy link
Contributor

No worries! I'm glad to see that we could get the issue resolved :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants