vscode-powershell icon indicating copy to clipboard operation
vscode-powershell copied to clipboard

PowerShell code folding is not working for here strings

Open imacks opened this issue 10 years ago • 24 comments

still no code folding if using here strings :( or #region for that matter.

function New-VSCodeCannotFold {

$I = @'
cannot fold
'@    

#region Can't fold a region

$b = 'foobar'
$c = 'foobar'
$d = 'foobar'

#endregion

}

imacks avatar May 13 '16 08:05 imacks

This is a VSCode issue at this point in time. It supplies the folding based purely on indentation level. It does not allow the extension/language to participate in determining what folds. See https://github.com/Microsoft/vscode/issues/3422

rkeithhill avatar May 13 '16 14:05 rkeithhill

Yep, unfortunately we can't help with that at the moment. I'm hoping that the code folding feature is going to be improved in the near future.

daviwil avatar May 13 '16 14:05 daviwil

I'm going to re-open this issue as a way to track the common request that code folding be improved. This is an issue that still needs to be fixed by the VS Code team.

daviwil avatar May 15 '16 23:05 daviwil

Information: #region does work inside functions which the first 4 spaces. But not outside a function, or after 5 spaces and more. See more in closed issue #129

johlju avatar Jul 21 '16 15:07 johlju

Adding a comment block inside of a function also impact the folding of code

and <# Comment #> image

robplank avatar Aug 09 '16 21:08 robplank

Yup, same issue. VSCode folds based on indentation level. The language extension does not get a chance to participate in code folding to provide more semantics-aware folding. Too bad. I hope VSCode can add this before too long.

rkeithhill avatar Aug 09 '16 22:08 rkeithhill

I would love to be able to fold at #region as well.

adbertram avatar Aug 25 '16 13:08 adbertram

Does a new GitHub issue need to be created for #region/#endregion support?

edit: Nevermind? If I read this correctly, the issue is a limitation with VS Code's code folding feature?

sgtoj avatar Sep 21 '16 12:09 sgtoj

@sgtoj yep, #region/#endregion support falls under this category as well.

daviwil avatar Sep 21 '16 14:09 daviwil

howdy y'all,

is there a VSCode issue for this? if so, would some kind person please point me to it?

take care, lee

LeeDailey avatar Feb 24 '17 11:02 LeeDailey

@LeeDailey See https://github.com/Microsoft/vscode/issues/3422

rkeithhill avatar Feb 24 '17 15:02 rkeithhill

howdy rkeithhill,

thank you! [grin] my search talent was not up to snuff ...

take care, lee

LeeDailey avatar Feb 25 '17 00:02 LeeDailey

VSCode team added region folding support! Please open a new issue if you see any problems.

TylerLeonhardt avatar Dec 06 '17 18:12 TylerLeonhardt

While region support has been added, here strings in PowerShell are still a problem.

rkeithhill avatar Dec 06 '17 19:12 rkeithhill

Good point - I missed that part of the issue. I'll reopen this and rename it to specify here strings

TylerLeonhardt avatar Dec 06 '17 21:12 TylerLeonhardt

Hi, just want to drop an idea here about the powershell here strings. Would it be better to add an indenting feature in powershell, which removes the leading (indenting) whitespace block.

There they are already a pain in the ass, when you are refactoring a block of code. iE put an IF around it, you ident the block. The here-string breaks this refactoring.

Don't have any idea about the syntax, but this example shows the concept:

if ($true){
    write-Host head
    write-host @@"
        Line 1
          Line 2
    "@@ 
}
# output
# head
# Line 1
#   Line 2

fbehrens avatar Dec 16 '17 10:12 fbehrens

So, according to this, the VSCode Team has implemented an API for code folding. I'm sure this is on the implementation radar somewhere, @rkeithhill ?

mpearon avatar Mar 12 '18 17:03 mpearon

@mpearon Thanks for the pointer. We'll definitely be looking at this but keep in mind that it is a "proposed" API with limitations i.e.:

you cannot publish an extension to the Marketplace that uses the enableProposedApi attribute.

So we will be tracking development of this API but we will need to wait until it's done before rolling it out with the PowerShell extension.

rkeithhill avatar Mar 13 '18 02:03 rkeithhill

@rkeithhill - I completely understand! :) I'm just glad you guys are aware of it. I'm excited to see the magic happen!

mpearon avatar Mar 13 '18 23:03 mpearon

Looks like it's official! https://code.visualstudio.com/updates/v1_23#_folding-provider-api

fromthewoods avatar May 08 '18 14:05 fromthewoods