Azure / Azure/bicep

Pasting JSON as Bicep should follow current indentation at the paste location

Open
#9,598 0 comments 0 reactions 0 assignees View on GitHub
devdiv story: decompiler
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

> Is there a way we can take into account the current indent level here?
> For example, if I paste `{"baz": "ghi"}` here (`|`):
```bicep
var bar = {
def: |
}
```
> Currently results in:
```bicep
var bar = {
def: {
baz: 'ghi'
}
}
```
> Whereas ideally it should be:
```bicep
var bar = {
def: {
baz: 'ghi'
}
}
```
> `FormatHelper.ToFormattedTextWithNewIndentation()` is the method I used for the single -> multi line object code fix provider - might be helpful here.

_Originally posted by @anthony-c-martin in https://github.com/Azure/bicep/pull/9519#discussion_r1069633156_

Contributor guide

Open the contributing guide

Research direction

Start with FormatHelper.ToFormattedTextWithNewIndentation() and trace the JSON-to-Bicep paste handling path. Compare indentation at the paste location with the issue's nested-object example, and verify that the resulting text matches the expected formatting.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.