Skip to content

Formatting regression: Comments separated by blank lines inherit indentation of previous lines #1245

@e-miz

Description

@e-miz

Describe the bug

In version 1.21, comments separated by blank lines were not automatically aligned with comments on preceding lines. In version 1.22, comments separated by blank lines are now automatically aligned with comments on preceding lines, even when blank lines are present between commented lines. This can occur when the last line of a section will be commented out and a new section will begin (as indicated by a comment).

Expected Behavior

# Section 1

variables:
  - "C"
  - 1
  - false
  # four: true

# Section 2

more_variables:
  - "A"
  - 2

Current Behavior

# Section 1

variables:
  - "C"
  - 1
  - false
  # four: true

  # Section 2

more_variables:
  - "A"
  - 2

Steps to Reproduce

  1. Format the example given in "Expected Behavior" within VSCode with the YAML extension.

The comment for "Section 2" will be aligned with the commented out list item in the preceding section, despite a blank line being present.

Environment

Note I have not tested this in other environments.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions