PowerShell / PowerShell/vscode-powershell

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

Open
#2,675 9 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Code Formatting Issue-Bug
Dominant language
TypeScript
Stars
1.9k
Forks
547
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file, test, or entry point is identified. Start by trying to reproduce the sporadic copy-and-paste deletion in a PowerShell PS1 file using the reported VS Code, PowerShell extension, and PowerShell versions, with the supplied settings.zip as context; done means identifying the cause and confirming unrelated text is no longer deleted.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, typescript, vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.