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
}
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
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.
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.
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
Adding a comment block inside of a function also impact the folding of code
and
<#
Comment
#>

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.
I would love to be able to fold at #region as well.
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 yep, #region/#endregion support falls under this category as well.
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 See https://github.com/Microsoft/vscode/issues/3422
howdy rkeithhill,
thank you! [grin] my search talent was not up to snuff ...
take care,
lee
VSCode team added region folding support! Please open a new issue if you see any problems.
While region support has been added, here strings in PowerShell are still a problem.
Good point - I missed that part of the issue. I'll reopen this and rename it to specify here strings
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
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 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 - I completely understand! :) I'm just glad you guys are aware of it. I'm excited to see the magic happen!
Looks like it's official! https://code.visualstudio.com/updates/v1_23#_folding-provider-api
Since there is an official provider now, has this become an active pursuit, @rkeithhill?
@mpearson It can be pursued with enough 馃憤's!
Don't expect it right away because everyone has been tied down with other things:
I'm fighting performance issues with intellisense, Rob's but dealing with some PowerShell/PowerShell tasks.
Keith may be able to pick this up. He'll have to chime in on that.
This is an open source project so feel free to take a crack at it, otherwise, we'll get to it as soon as we can. 馃榾 There's lots to do!
@tylerl0706 I completely understand! I really wish I was to the point where I could legitimately contribute, because this is such a cool project. I'll working on getting there, but I'm still very fresh.
I appreciate all that you guys are doing!
Going to dupe this to https://github.com/PowerShell/vscode-powershell/issues/1276 馃槃
Most helpful comment
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.