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

Property names/keys with more than 80 symbols get prefixed with question mark ?, and colon : gets wrapped onto the next line

Open MurzNN opened this issue 2 years ago • 3 comments

Describe the bug

I have a YAML file like this:

services:
  Drupal\some\long\service\name\name\name\name\name\name\name\name\na\length_80:
    tags:
      - name: event_subscriber

  Drupal\some\long\service\name\name\name\name\name\name\name\name\nam\length_81:
    tags:
      - name: event_subscriber

And the formatter always changes it to the:

services:
  Drupal\some\long\service\name\name\name\name\name\name\name\name\na\length_80:
    tags:
      - name: event_subscriber

  ? Drupal\some\long\service\name\name\name\name\name\name\name\name\nam\length_81
  : tags:
      - name: event_subscriber

So, names/keys with a length of more than 80 symbols get prefixed with the question mark ?, and the colon : gets wrapped onto the next line.

Expected Behavior

The formatter should keep the original formatting.

Current Behavior

See above.

Steps to Reproduce

  1. Create a YAML file with the content in the first code block.
  2. Format the file.
  3. See the wrong changes.

Environment

VS Code version: 1.81.1 Commit: 6c3e3dba23e8fadc360aed75ce363ba185c49794 Date: 2023-08-09T22:18:39.991Z Electron: 22.3.18 ElectronBuildId: 22689846 Chromium: 108.0.5359.215 Node.js: 16.17.1 V8: 10.8.168.25-electron.0 OS: Linux x64 6.2.0-27-generic

MurzNN avatar Aug 23 '23 14:08 MurzNN

Seems the source of this issue comes from this Prettier issue https://github.com/prettier/prettier/issues/5599 and seems we should just bump the Prettier version to a fresher one?

MurzNN avatar Aug 23 '23 14:08 MurzNN

It may sound obvious, but may help someone experiencing the same issue.

A simple workaround for this is changing Print Width formatter settings to some higher value (e.g. 999).

image

nickshoe avatar Oct 05 '23 10:10 nickshoe

This was driving me nuts - I had to edit with "Language Mode : Yaml" but modify to "Language Mode: [anything else..]" before saving. Workaround from @nickshoe worked like a charm.

e-desouza avatar Jan 29 '24 19:01 e-desouza