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.

8 comments

works for me - when I put cursor on this line and hit Ctrl+/ to uncomment, the leading white space is preserved:

 yaml: some code

 

Webstorm 2017.3.3

0

you might not have checked the number of spaces carefully,

 

e.g.

# - name: install nginx

 

when you un-comment you should have 2-spaces leading (spaces before -), because when you cmd/ctrl + / you have 2 spaces

  - name: install nginx

 

currently I am using VSCode to edit YAML files.

0

To me, number of leading spaces on uncommenting is exactly the same as the number of spaces between `#` and `-`

0

Elena, try this to re-produce the bug, it's a tab indentation issue.

  # - name: install useful packages
# apt: name={{ item }} state=present update_cache=yes
# with_items:
# - vim
# - tree

 

un-comment last line, we get;

  # - name: install useful packages
# apt: name={{ item }} state=present update_cache=yes
# with_items:
# - vim
- tree

 

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.

# - name: install useful packages
# apt: name={{ item }} state=present update_cache=yes
# with_items:
# - vim
- tree

 

0

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?

0

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

0

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.

0

WebStorm does keep indentation when uncommenting - problems will only occur when uncommenting lines commented with Sublime, Atom, etc.

0

Please sign in to leave a comment.