YAML indentation rules do not work
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.132.1
- OS Version: Windows_NT x64 10.0.19045
Steps to Reproduce:
There are a number of problems with the `indentationRules` for YAML.
https://github.com/microsoft/vscode/blob/b10759526092db723a7217e7627ae309d74719f4/extensions/yaml/language-configuration.json#L31-L34
### 1. Starting an object does not indent
1. Type `foo:`
2. Press Enter
According to the `increaseIndentPattern`, this should increase the indent for the next line. Instead, the next line starts at the same indentation as the previous line.
If I create my own extension with exactly the same `language-configuration.json`, this does work:
### 2. Anchors are not handled
The rule attempts to allow an anchor to follow a property name and colon, but it looks like it has been copied verbatim from an XML language declaration because it uses `(&\\w+)?` instead of `(&\\w+)?`.
1. Type `foo: &anchor`
2. Press Enter
The next line should be indented, but it starts at the same indentation as the previous line.
Since VS Code doesn't seem to use the indentation rules (see problem 1), I can demonstrate this with my own extension that uses the same `language-configuration.json`.
If you change `&` to just `&`, it fixes it:
### 3. No Indent After Block Scalar
The indentation rules do not indent after starting a block scalar. When you start a block scalar using either `|` or `>`, the next line needs to be indented, but the indentation rules don't take this into account.
1. Type `foo: |`
2. Press Enter
The next line should be indented, it it starts at the same indentation as the previous line.
Unlike the other problems, the indentation rules do not attempt to handle this, but I think it should be a simple addition.
Contributor guide
Assessment
This issue has not been assessed yet.