vscode-powershell: Run selection with F8 causes executed code to be recalled / duplicated into the integrated console prompt

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

My vscode-powershell extension updated this morning to ms-vscode.powershell@2022.6.1 and I’m having an issue where the selection of code I’m running with F8 is executed but then is recalled immediately into the integrated console prompt.

Example:

=====> PowerShell Integrated Console v2022.6.1 <=====

PS> $PSVersionTable

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

PS> Write-Output -InputObject "Hi!"
Hi!
PS> Write-Output -InputObject "Hi!"

It’s as if the console history is being immediately recalled into the console prompt without additional input.

Rolling back to ms-vscode.powershell@2022.5.1 fixes the issue:

=====> PowerShell Integrated Console v2022.5.1 <=====

PS> $PSVersionTable

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

PS> Write-Output -InputObject "Hi!"
Hi!
PS>

The latest preview extension ms-vscode.powershell-preview@2022.6.2 exhibits the same behaviour as v2022.6.1.

Could this be caused by https://github.com/PowerShell/PowerShellEditorServices/pull/1823?

PowerShell Version

PS> $PSVersionTable

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

Visual Studio Code Version

PS> code --version
1.68.1
30d9c6cd9483b2cc586687151bcbcd635f373630
x64

Extension Version

PS> code --list-extensions --show-versions | Select-String powershell

ms-vscode.powershell@2022.6.1
ms-vscode.powershell-preview@2022.6.2

Steps to Reproduce

Write-Output -InputObject "Hi!"
  1. With ms-vscode.powershell@2022.6.1 installed, launch the PowerShell integrated console.
  2. Select line(s) of code in the editor window and run using F8.
  3. The code is executed.
  4. The executed lines of code are recalled immediately into the integrated console prompt.

Visuals

No response

Logs

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 8
  • Comments: 19 (7 by maintainers)

Most upvoted comments

Super happy to confirm that v2022.6.3 is working fine now!!! Thanks a lot everyone 😄 Great effort!

Fix in PR!

Bless you - I have been trying to figure this out for several days. Its not show-stopping but just very annoying. At first it seemed related to the terminal settings in VS Code but nothing I changed or set back to default helped. Reinstalled a bunch of things and updated other modules. Finally tracked it down to the module and found this article/PR. I updated the module to v2022.6.3 and can verify the issue is gone!!!

ed… too many 2s…

Sorry about that! We did not mean to introduce that bug, it was clearly very annoying. Ok, not that we mean to introduce any bug 😅

@tropez1971 @pascalkrielen @andschwa @cblackuk Just testing v2022.6.3-preview with the fix and I can no longer reproduce! 🚀 🙂

Working on getting a preview out right now! I got stuck trying to get a new end-to-end test in yesterday, sorry!

Yep, can no longer reproduce in v2022.6.3 🚀 🥳 - Thanks all! 🙂

Thanks @andschwa for your efforts 😃 really appreciate it!

For @tropez1971 and @pascalkrielen - for now I would suggest manually downgrading to v2022.5.1 which is what I did for now 😃 I hope that helps 😃

Wow! Awesome! 🚀 Thanks for the quick turnaround! @andschwa @SeeminglyScience!

That is so awesome 😃 thanks for such a quick turnaround 😃

Reproduced on a different Windows system than I initially submitted the issue on:

Windows 10 21H1 (OS Build: 19043.1766)

=====> PowerShell Integrated Console v2022.6.1 <=====

PS C:\Users\dab> $PSVersionTable

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

PS C:\Users\dab> 
PS C:\Users\dab> Write-Output -InputObject "Hi!"
Hi!
PS C:\Users\dab> Write-Output -InputObject "Hi!"

I can also reproduce this on Linux with WSL on the same system as above:

dab@DESKTOP:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
=====> PowerShell Integrated Console v2022.6.1 <=====

PS /home/dab> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.5
PSEdition                      Core
GitCommitId                    7.2.5
OS                             Linux 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS /home/dab> 
PS /home/dab> Write-Output -InputObject "Hi!"
Hi!
PS /home/dab> Write-Output -InputObject "Hi!"

To me it was on a Windows Sever 2019 and WS2022 - brand new session, just after upgrading - the F8 button started pasting the code “twice” as @dbrennand explained.

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

And

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

It is also worth mentioning that I can repro it on Windows PowerShell 5.1 on the same boxes 😃

Ok seems to be Windows-only? Repro’d (without throwing an error first) on PS 7.2.4 on Windows.

Yay, glad to hear it @dbrennand! We’re looking to move that preview to stable today, give it a good thorough whack of testing!

Thanks @dbrennand - I am having the same issue on multiple systems.