-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
Comment handling is off by one #575
Comments
The value you get from |
Maybe the wording is confusing but to me the comment before |
The logic is that a comment with no empty lines after it gets attached to the next node. "A comment level1" is a comment before the block mapping with a single key, The comment "A comment level3.2" is also attached to the next node, the key-value pair with the key Perhaps your confusion is arising from comments being attachable to mappings as well as key-value pairs? |
I don't know, there is indeed something I don't understand even with the explanation. Anyway, feel free to discard the issue if it works as intended. |
Describe the bug
When dealing with nested object and comments, some comments get pushed into the parent until we reach the last level. Only the last element is correct.
To Reproduce
https://codesandbox.io/p/devbox/2cgfk7?file=%2Findex.js%3A15%2C1
Note
Check terminal
With this yaml
When we
get('level1')
the value ofcommentsBefore
is# A comment level2
, which is incorrect.Then it's the same for all levels until
level3.1
, this node does not have a comment andlevel3.2
have the correct one.Expected behaviour
commentsBefore
should be assigned to the right node. Or at least it should be off by one consistently.I know the support for comment is not complete and an issue was opened/closed before regarding this. I don't think the closing was correct as the behavior is inconsistent.
Versions:
yaml
: 2.5.1The text was updated successfully, but these errors were encountered: