grafana / grafana/jsonnet-language-server
Formatter Incorrectly Rewrites Object Merging in List Comprehensions
- Dominant language
- Go
- Stars
- 223
- Forks
- 33
- PR merge metrics
- No merged PRs in 30d
Description
The Grafana Jsonnet formatter in VS Code incorrectly rewrites syntactically valid object merging (+) inside a list comprehension. It replaces an object concatenation operation with an explicit key-value pair, which is a destructive change that alters the code's meaning and assumptions about the data structure.
**Steps to Reproduce:**
- VSCode plugin `grafana.vscode-jsonnet 0.7.2`
- Use the VS Code command "Format Document" (or allow formatting on save).
```
env: [{ name: e.key } + e.value for e in std.objectKeysValues(env_)]
```
**Actual Behavior**
The formatter aggressively rewrites the line, changing the logic from object merging to direct key assignment. The code is incorrectly changed to:
```
env: [ { name: e.key, value: e.value } for e in std.objectKeysValues(env_) ]
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the issue with the provided list-comprehension example using the VS Code "Format Document" command and inspect the formatter entry point for this transformation. Trace why object merging with + becomes a key-value pair, then verify that formatting preserves the merge and the code's meaning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, vscode
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100