Skip to content

Format Document command corrupts text strings in Powershell documents #2870

Closed
@u2ill

Description

@u2ill

Issue Type: Bug

Take the following 3 lines of orignal Powershell code:

Write-Output "`n`rTurning $State the $scope environment..."
$i=1+2|ft
Write-Output "`n`rCopied tags from RDS instance '$($vars.rdsInstanceIdentifier)' to RDS snapshot '$($vars.DBSnapshotIdentifier)'"

When performing a "Format Document" command on this code in a Powershell file, VS Code changes the code to the following:

Write-Output "`n`rTurning $State $scope environment..."
$i = 1 + 2 | Format-Table
Write-Output "`n`rCopied tags from RDS instance '$($vars.rdsInstanceIdentifier)$($vars.DBSnapshotIdentifier)'"

Line 2 is the only correctly formatted line - spaces are added and the alias is expanded.
But line 1 and 3 have their data corrupted!
Line 1 - the word 'the' between the $state and $scope variables has been removed.
Line 3 - the 3 words 'to RDS snapshot' between the two variables on the line have been removed.

There seems to be a problem when formatting data embedded in text quotes. I ran the same 3 lines through the PSScriptAnalyzer that is included in VS Code, and the output is as expected. Something in VS Code (not PSScriptAnalyzer) is corrupting data when formatting Powershell documents.

Extension version: 2020.6.0
VS Code version: Code 1.47.3 (91899dcef7b8110878ea59626991a18c8a6a1b3e, 2020-07-23T13:12:49.994Z)
OS version: Windows_NT x64 10.0.17134

System Info
Item Value
CPUs Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz (4 x 2808)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.89GB (3.94GB free)
Process Argv
Screen Reader no
VM 0%

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions