redhat-developer / redhat-developer/vscode-yaml

Formatter should not squash multiline string values

Open
#987 4 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug

I'm attempting to embed a 50+ line INI file in a ConfigMap as a string. Whenever I save the file that section loses all of its formatting and it gets squashed into a single line sprinkled with literal \n and "magic line" comment blocks. This makes the embedded INI file unreadable for editing the configuration values so I have to go in and manually find-replace the formatting back how it was and re-indent the block.

Expected Behavior

Format-on-save should not mangle multiline strings. Newlines exist for a reason.

Current Behavior

Format-on-save mangles my strings.

Steps to Reproduce

  1. Create the following YAML file in VSCode:
apiVersion: v1
kind: ConfigMap
metadata:
  name: foo
  namespace: bar
data:
  baz.ini: |+
    "[section1]
    a = b
    x = y
    [section2]
    foo=bar"
  1. Save the file.

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

Reproduce the issue in VS Code using the YAML ConfigMap example and format-on-save. Start by tracing the YAML formatter entry point responsible for multiline scalar strings; done means saving the file preserves the multiline value and does not insert literal \n text or comment blocks.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.