bicep icon indicating copy to clipboard operation
bicep copied to clipboard

VS Code folding gets confused if multi line string is not indented

Open afscrome opened this issue 5 years ago • 3 comments

Bicep version VS Code 0.3.255

Describe the bug Foldi

To Reproduce

Open the following up in VS Code, then attempt to fold the resource block

resource foo 'Microsoft.AAD/domainServices@2021-03-01' = {
  name: '''
foo
  '''
}

Rather than collapse the whole resource, it only gets partially collapsed (up until the multi line string)

image

Additional context

The problem seems to be caused by the contents of the multi line string not being indented. If you indent the foo line by just a single space (like below), then the folding behaves correctly

resource foo 'Microsoft.AAD/domainServices@2021-03-01' = {
  name: '''
 foo
  '''
}

image

afscrome avatar Apr 29 '21 20:04 afscrome

Good catch!

alex-frankel avatar Apr 29 '21 20:04 alex-frankel

I think to get correct behavior here, we will need to implement the LSP folding ranges in the language server.

majastrz avatar Apr 29 '21 21:04 majastrz

Thanks for your patience — this was recently picked up as an outstanding open issue for the Bicep team to review, and apologies for the long wait here.

Good catch originally, and thanks to @majastrz for pinpointing the real fix back in April 2021: to get this right we'd implement folding ranges in the Bicep language server (LSP) rather than rely on the editor's default indentation-based folding, which is what gets confused when the contents of a ''' multi-line string aren't indented.

I had a look on Bicep 0.43.8 and it doesn't look like the language server provides LSP folding ranges yet, so folding is still driven by VS Code's indentation/marker heuristics — meaning this is still outstanding rather than fixed.

I'm going to leave this open as the tracked enhancement for language-server folding ranges. If you've found the folding behaves correctly for you in a recent build, let me know and I'll close it out — and feel free to reopen if it resurfaces.

torreymicrosoft avatar Jun 10 '26 00:06 torreymicrosoft