redhat-developer / redhat-developer/vscode-yaml

Peculiar behavior around anchors and comments

Open
#459 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

formatter
Dominant language
TypeScript
Stars
829
Forks
260
Avg merge
5h 43m
Merged PRs (30d)
1

Description

Describe the bug

Expected Behavior

I have this yaml:

when: &shall
  # we three meet again; in lightning, thunder and in
  rain:

Current Behavior

It moves the comment to the anchor:

when: &shall # we three meet again; in lightning, thunder and in
  rain:

Expected Behavior 2

It's even worse if the comment is long:

when: &shall
  # we three meet again; in lightning, thunder and in lightning, thunder and
  rain:

Current Behavior 2

It moves the anchor down to the next line

when:
  &shall # we three meet again; in lightning, thunder and in lightning, thunder and
  rain:

Environment

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing issue #459 in the VS Code YAML support extension using the YAML examples in the report, focusing on anchors and preceding comments. Trace the formatting or parsing entry point responsible for the output; done means comments remain in their original position and anchors are not moved when comment length changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.