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

Blank lines and comments after null element get lost #125

Closed
andresmgot opened this issue Sep 27, 2019 · 7 comments
Closed

Blank lines and comments after null element get lost #125

andresmgot opened this issue Sep 27, 2019 · 7 comments
Labels
bug Something isn't working

Comments

@andresmgot
Copy link

Hi!

I found a small usability problem when a null component gets followed by a comment (related to a different node). The indentation of the comment get lost:

> console.log(text)
## Comment 1
foo:

## Comment 2
bar: foo

undefined
> console.log(yaml.parseDocument(text).toString())
## Comment 1
foo:

  null ## Comment 2
bar: foo

undefined

The issue get fixed if the null key gets comment but I am working with YAML that I cannot control.

Am I missing something?

Thanks in advance! I am happy to work in a PR if this is not an expected behavior.

@eemeli eemeli added the bug Something isn't working label Sep 28, 2019
@eemeli
Copy link
Owner

eemeli commented Sep 28, 2019

Unfortunately no, you're not missing anything -- that definitely counts as a bug. PR would be welcome.

@andresmgot
Copy link
Author

Thanks for the feedback @eemeli. Any pointers about what code should I look for to submit a patch?

@eemeli
Copy link
Owner

eemeli commented Sep 30, 2019

Maybe around here? If it's not exactly that, any fix will most likely touch parseMap.js and possibly parseUtils.js as well.

@eemeli
Copy link
Owner

eemeli commented Oct 6, 2019

This turned out to be related to the same fundamental issue as #126, and solving this actually improved the solution for the other issue as well. I was completely wrong on my earlier guess for the root cause, as it was the CollectionItem CST node parser that was grabbing the comment for the preceding collection value node.

Previously, the collection item parser consumed blank lines and comments until it either found the value, or detected the start of the following node. Now it'll only consume an inline comment, and let the parent handle the rest.

@andresmgot
Copy link
Author

Awesome. I will test it and let you know if I find any issues. Thank you!

@eemeli
Copy link
Owner

eemeli commented Oct 7, 2019

Fix included in patch release 1.7.1.

@andresmgot
Copy link
Author

👍 I can confirm that works as expected. The only difference I see now is that some initial spaces are being deleted:

 ## Add sidecars to the pod.
 ## e.g.
 # - name: your-image-name
-  # image: your-image
-  # imagePullPolicy: Always
-  # ports:
-  # - name: portname
-  #   containerPort: 1234
+# image: your-image
+# imagePullPolicy: Always
+# ports:
+# - name: portname
+#   containerPort: 1234

But that's a different/less important issue. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants