Issue Type: Bug
Code formatting does not behave properly when declaring a hashtable in a IF condition.
Set your codeFormatting options to:
"powershell.codeFormatting.ignoreOneLineBlock": true,
"powershell.codeFormatting.openBraceOnSameLine": true,
"powershell.codeFormatting.newLineAfterCloseBrace": true,
"powershell.codeFormatting.newLineAfterOpenBrace": true,
Write the following statement
if ($test -eq $null) {$test = @{}}
if ($test -eq $null) {
$test = @{ }
}
Once formatted, they will appear as :
if ($test -eq $null) { $test = @{ }
}
if ($test -eq $null) {
$test = @{ }
}
Trying the same thing with test assignment being an array @() instead of a hashtable work properly .
if ($test -eq $null) { $test = @() }
if ($test -eq $null) {
$test = @()
}
Extension version: 2019.5.0
VS Code version: Code 1.36.0 (0f3794b38477eea13fb47fbe15a42798e6129338, 2019-07-03T13:25:46.372Z)
OS version: Windows_NT x64 10.0.17763
System Info
|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz (8 x 3500)|
|GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled|
|Load (avg)|undefined|
|Memory (System)|31.89GB (13.75GB free)|
|Process Argv||
|Screen Reader|no|
|VM|0%|
Code formatting functionality is provided by PSScriptAnalyzer. Can you submit this bug on that project - https://github.com/powershell/scriptanalyzer/issues? Thanks.
cc @bergmeister for visibility