Skip to content

Unrelated Text in PowerShell PS1 File Being Deleted After Copy and Pasting Text #2675

Open
@DesertBear

Description

@DesertBear

System Details

System Details Output

### VSCode version: 1.44.0 2aae1f26c72891c399f860409176fe435a154b13 x64

### VSCode extensions:       
ms-vscode.powershell@2020.4.0


### PSES version: 2.1.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue Description

Sporadically, when copy and pasting text from one part of a PowerShell PS1 script to another part in the same script, VS Code deletes other unrelated text in the script. It's pretty bad because if you don't happen to notice what it has done, the file will be saved with those errors.

It's difficult to reliably reproduce this issue, as it happens sporadically.

It's not dependent on any one particular file, it can happen in any PS1 file (I only use PowerShell files in VS Code, so can't comment on other file types).

It happens whether using keyboard shortcut keys (CTRL + C, CTRL + V) or the right-click context menu.

After closing VS Code and re-opening the PS1 file, VS Code starts working OK again – copy and pasting works correctly.

It has only started doing it recently (probably in the last few months of so; definitely in 2020). I don't use any preview versions, only general availability versions of VS Code, PowerShell 7 and the PowerShell Extension.

Expected Behaviour

-- It should just copy and paste the text.

Actual Behaviour

-- Sporadically, when copy and pasting text from one part of a PowerShell PS1 script to another part in the same script, VS Code deletes other unrelated text in the script.

In the screenshots below, it's deleting certain letters in two lines. However when undoing and then re-copying and re-pasting, it may delete different letters in those two lines (for example it may say "Press Enter key to ex" instead).

Screenshot A:
Screenshot A

Screenshot B:
Screenshot B

Screenshot C:
Screenshot C

VS Code Settings

VS Code Settings file:
settings.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions