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
Inconsistent comments handling for empty nodes #491
Comments
This is pretty much the same as #490. As I mention there:
|
yeah, thanks for answering and seems it is the same issue as 490 as you said. The comments in yaml can be practically anywhere and they are not bound in any way to the scalar except visually. |
I would reiterate that you're welcome to suggest changes in the logic for comment attachment, but you'll probably need to submit a PR yourself. |
I see, thank you for opportunity to contribute. But unfortunately I'm not able to work on third party projects right now. What I wanted to figure out is if this is considered as a bug and if yes then if it is planned to be fixed by active contributors. Otherwise we would probably just revert to previous stable version as of now |
Describe the bug
Inconsistent behaviour of parseDocument function.
Once yaml contains deep hierarchical of empty nodes the comment from the next node on a top level is getting ignored. Instead it appears on a wrong level of hierarchy. See example below.
To Reproduce
Consider yaml
Use
const document = yaml.parseDocument(fileSource, { sortMapEntries: true });
Expected behaviour
The comment "@desc: Settings button configuration.\n@class: Button" should be on "button" Scalar on level:
document.contents.items[0].value.items[1].value.comment
.Actual behaviour
The comment "@desc: Settings button configuration.\n@class: Button" appears on "iconColor.open" level Scalar:
document.contents.items[0].value.items[0].value.items[0].value.comment
.Versions (please complete the following information):
Node v20.0.0
yaml
: [e.g. 1.10.0 or 2.0.0-2]2.3.1
According to my local tests the bug was introduced in 2.0.0-4
Additional context
The issue will be solved if I explicitly apply
null
to empty node in yaml, e.g.The text was updated successfully, but these errors were encountered: