redhat-developer / redhat-developer/vscode-yaml

tabSize setting is inconsitently applied

Open
#976 0 comments 2 reactions 0 assignees View on GitHub

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:
image

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:
image

This isn't a problem with tab size 2, since - name: is implicitly tab size 2.

Steps to Reproduce

  1. set tabSize to 4
  2. run formatting

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.