Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codeFormatting.IgnoreOneLineBlock / hashtable problem #2071

Closed
itfranck opened this issue Jul 7, 2019 · 3 comments
Closed

codeFormatting.IgnoreOneLineBlock / hashtable problem #2071

itfranck opened this issue Jul 7, 2019 · 3 comments

Comments

@itfranck
Copy link

itfranck commented Jul 7, 2019

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%
@rkeithhill
Copy link
Contributor

Code formatting functionality is provided by PSScriptAnalyzer. Can you submit this bug on that project - https://github.com/powershell/scriptanalyzer/issues? Thanks.

@TylerLeonhardt
Copy link
Member

cc @bergmeister for visibility

@itfranck
Copy link
Author

itfranck commented Jul 8, 2019

PowerShell/PSScriptAnalyzer#1284

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants