vscode-yaml-sort icon indicating copy to clipboard operation
vscode-yaml-sort copied to clipboard

Comment processor messes up yml indentation

Open stefan-hinterberger opened this issue 1 year ago • 4 comments

Running the plugin with the comment processor enabled seems to mess up the indentation of the yml keys. This seems to happen regardless of the indentation of the comment itself or the sort mode (I tried both "Custom Sort 1" and the generic "Sort YAML"). Indent is set to 2 (which should match the one in the test yml file). I also tried deactivating other processors or other plugins that may mess with this one, did not seem to make a difference. VS Code version is 1.79.2

Example input 1

# Spring boot configuration
server:
# Port to be used by the server
  port: 8080
  servlet:
#   Context path of the application
    context-path: /mws
# The server should support graceful shutdown, allowing active requests time to complete.
  shutdown: graceful

Example output 1

# Spring boot configuration
server:
  # Port to be used by the server
port: 8080
  servlet:
    #   Context path of the application
context-path: /mws
# The server should support graceful shutdown, allowing active requests time to complete.
  shutdown: graceful

Example input 2 - adjusting comments to indent of the keys

# Spring boot configuration
server:
  # Port to be used by the server
  port: 8080
  servlet:
    # Context path of the application
    context-path: /mws
  # The server should support graceful shutdown, allowing active requests time to complete.
  shutdown: graceful

Example output 2

# Spring boot configuration
server:
    # Port to be used by the server
port: 8080
  servlet:
        # Context path of the application
context-path: /mws
  # The server should support graceful shutdown, allowing active requests time to complete.
  shutdown: graceful

stefan-hinterberger avatar Jun 27 '23 13:06 stefan-hinterberger

Hello @stefan-hinterberger, I fixed a lot of bugs in the last weeks. In the latest version (6.5.9) I cannot confirm your issue. I assume it is solved in the meanwhile. If not, feel free to open this issue again.

pascalre avatar Oct 28 '23 11:10 pascalre

Hello, I tried the versions 6.5.9 and 6.5.10 (latest) on the provided example above because I'm facing the same issue and I can confirm the problem is still present.

J-PC avatar Dec 20 '23 14:12 J-PC

@J-PC can you provide a code example and your settings?

pascalre avatar Jan 21 '24 22:01 pascalre

I faced the same issue with version v6.5.14, without any change to the default configuration. For the reproduction.

Starting from:

# Environment for the openshift deployment


el:
  api:
    org-api-keys:
      1: 'toto'

eq:
#  deployments:
#    dashboard:
#      enabled: true
#      api:
#        url: tata
#        key: tutu
#      data:
#        environment: INT
#        manifest-file: file:/data/workdir/manifest.json
  auth:    
    org-sso-ids:
      1: 'pwet'
    org-organization-uuids:
      1: 'pwet'

management:
  modules:
    cp:
      enabled: true
    relationship: true
    workflows-enabled: false

allow:
  enabled: false

Using the sort yaml, we end up with (auth is now a first level key):

---
el:
  api:
    org-api-keys:
      '1': toto
eq:
  #  deployments:
#    dashboard:
#      enabled: true
#      api:
#        url: tata
#        key: tutu
#      data:
#        environment: INT
#        manifest-file: file:/data/workdir/manifest.json
auth:
    org-sso-ids:
      '1': pwet
    org-organization-uuids:
      '1': pwet
management:
  modules:
    cp:
      enabled: true
    relationship: true
    workflows-enabled: false
allow:
  enabled: false# Environment for the openshift deployment

The expected yaml would be:

---
# Environment for the openshift deployment
allow:
  enabled: false
el:
  api:
    org-api-keys:
      '1': toto
eq:
#  deployments:
#    dashboard:
#      enabled: true
#      api:
#        url: tata
#        key: tutu
#      data:
#        environment: INT
#        manifest-file: file:/data/workdir/manifest.json
  auth:
    org-organization-uuids:
      '1': pwet
    org-sso-ids:
      '1': pwet
management:
  modules:
    cp:
      enabled: true
    relationship: true
    workflows-enabled: false

UyttenhoveSimon avatar Feb 16 '24 07:02 UyttenhoveSimon