redhat-developer / redhat-developer/vscode-yaml
tabSize setting is inconsitently applied
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 829
- Forks
- 260
- Avg merge
- 5h 43m
- Merged PRs (30d)
- 1
Description
Describe the bug
I have tabSize set to 4:
"[yaml]": {
"editor.insertSpaces": true,
"editor.tabSize": 4,
"editor.autoIndent": "keep",
"diffEditor.ignoreTrimWhitespace": false,
"editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": true
}
}
vscode-yaml inconsistently applies the tab size, resulting in mixed indents of 4 and 6.
Here's an example of some yaml from a Github Action I'm working on that the extension should not be reformatting:
# ...
runs:
using: "composite"
steps:
- name: Setup environment variables
id: env_vars
run: |
export AWS_REGION=us-west-2 >> $GITHUB_ENV
# ...
You can see in this screenshot that tab size is consistently 4 spaces:
Expected Behavior
When formatting happens, the above should be left untouched
Current Behavior
vscode-yaml removes the spaces after the hyphen and adds an unnecessary indent, reformatting to the following:
runs:
using: "composite"
steps:
- name: Setup environment variables
id: env_vars
run: |
export AWS_REGION=us-west-2 >> $GITHUB_ENV
This uses tab size 4 sometimes, other times tab size 2. The problem is removing the spaces after the hyphen... - name: should not be changed to - name:!
You can see in this screenshot that this is inconsistent tab size; id and run are half indented:
This isn't a problem with tab size 2, since - name: is implicitly tab size 2.
Steps to Reproduce
- set tabSize to 4
- run formatting
Environment
- Windows
- Mac
- Linux
- other (please specify)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the formatter behavior in vscode-yaml with tabSize set to 4 and the provided GitHub Actions YAML. Compare the formatted output with the expected unchanged indentation, including the spaces after -; done means formatting preserves the four-space layout and - name: spacing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, yaml
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100