Closed
Description
Issue Description
When a hash table is defined inside a function (whether a single- or multi-line definition), folding the function causes the fold to stop at the end of the hash table block rather than the end of the function block.
Reproducing the Issue
- Open the code below as a PowerShell script.
- Make sure configuration option "powershell.codeFolding.showLastLine" is set to true.
- Move the cursor to the function statement on line 3 and press
<Ctrl>+<Shift>+[
(on Windows) to fold the whole function.
Note that the fold ends at line 23 rather than line 28 as expected. - Unfold the function line (
<Ctrl>+<Shift>+]
on Windows) - Move the cursor to the hash table definition on line 18 and fold the multi-line definition.
Note that the fold swallows the closing line 23 as well as the blank line 24 below it.
Code:
#region Region1
Write-Host "Hello."
function TestFunction {
param (
[Parameter(Mandatory = $true,
Position = 0)]
[string]$Param1
)
Write-Host "Testing..."
$NewArray = @(
ArrayValue1
ArrayValue2
ArrayValue3
ArrayValue4
)
$NewHashTable = @{
HashTableValue1 = 1
HashTableValue2 = 2
HashTableValue3 = 3
HashTableValue4 = 4
}
if ($true) {
Write-Host "True is $true"
}
}
#endregion
Bonus Issue Test
- Put only the hash table definition in its own file (see code below).
Note that nothing is marked as foldable and the keyboard or palette commands do nothing.
Code:
$NewHashTable = @{
HashTableValue1 = 1
HashTableValue2 = 2
HashTableValue3 = 3
HashTableValue4 = 4
}
Environment Information
Visual Studio Code
Name | Version |
---|---|
Operating System | Windows_NT x64 10.0.17134 |
VSCode | 1.29.1 |
PowerShell Extension Version | 1.10.0 |
PowerShell Information
Name | Value |
---|---|
PSVersion | 5.1.17134.407 |
PSEdition | Desktop |
PSCompatibleVersions | 1.0 2.0 3.0 4.0 5.0 5.1.17134.407 |
BuildVersion | 10.0.17134.407 |
CLRVersion | 4.0.30319.42000 |
WSManStackVersion | 3.0 |
PSRemotingProtocolVersion | 2.3 |
SerializationVersion | 1.1.0.1 |
Visual Studio Code Extensions
Visual Studio Code Extensions(Click to Expand)
Extension | Author | Version |
---|---|---|
PowerShell | ms-vscode | 1.10.0 |