vscode-yaml
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
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
- Create a YAML file with the content in the first code block.
- Format the file.
- 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
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?
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).
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.