Editing YAML files spacing bug
When commenting a line in YAML file and un-commenting it indent order is not maintained. Mostly the one space is removed when un-commenting YAML lines.
# yaml: some code
yaml: some code
Spacing should remain similar when toggling comments.
Please sign in to leave a comment.
works for me - when I put cursor on this line and hit Ctrl+/ to uncomment, the leading white space is preserved:
yaml: some codeWebstorm 2017.3.3
you might not have checked the number of spaces carefully,
e.g.
when you un-comment you should have 2-spaces leading (spaces before -), because when you cmd/ctrl + / you have 2 spaces
currently I am using VSCode to edit YAML files.
To me, number of leading spaces on uncommenting is exactly the same as the number of spaces between `#` and `-`
Elena, try this to re-produce the bug, it's a tab indentation issue.
un-comment last line, we get;
Notice you get a single space removed not 2 spaces.
It should have been like below, at-least in my experience (tested on) Sublime Text and VSCode respect YAML indentation upon un-commenting.
Because if we don't take into consideration tab length on un-commenting or commenting YAML will become invalid.
So, do you mean that the number of spaces equal to `Indent` value (Settings | Editor | Code Style | YAML | Tabs and Indents, Indent) should be removed on un-commenting, instead of a single space?
I don't actually see your point. Can you provide an example where deleting a single space on uncommenting makes the code invalid? IMO, uncommenting should make the code look the same as it was before commenting. Commenting adds a single character, moving code 1 position right. Why should uncommenting move it 2 positions left?
Found similar request - https://youtrack.jetbrains.com/issue/PY-19430
Code might become ruined indeed if it was commented in Sublime, that adds an extra space after # when commenting out a code. But Webstorm doesn't do this, so deleting extra space on uncommenting will break the code commented with WebStorm
Elena,
Sublime / VSCode are similar in behaviour. It's probable that other editors Atom etc. have a similar approach.
Considering yaml files are all about keeping indentation and spacing accurate. Therefore it's appropriate to offset comments keeping TAB spacing of yaml file in perspective.
Additionally it look more pleasing to see the indentation and comments follow a visual flow when yaml is all about spacing.
WebStorm does keep indentation when uncommenting - problems will only occur when uncommenting lines commented with Sublime, Atom, etc.