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

Run selection with F8 causes executed code to be recalled / duplicated into the integrated console prompt #4041

Closed
6 tasks done
dbrennand opened this issue Jun 23, 2022 · 19 comments · Fixed by PowerShell/PowerShellEditorServices#1841
Assignees

Comments

@dbrennand
Copy link

dbrennand commented Jun 23, 2022

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 [email protected] 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 [email protected] 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 [email protected] exhibits the same behaviour as v2022.6.1.

Could this be caused by PowerShell/PowerShellEditorServices#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

[email protected]
[email protected]

Steps to Reproduce

Write-Output -InputObject "Hi!"
  1. With [email protected] 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

@dbrennand dbrennand added the Issue-Bug A bug to squash. label Jun 23, 2022
@ghost ghost added the Needs: Triage Maintainer attention needed! label Jun 23, 2022
@cblackuk
Copy link

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

@andyleejordan
Copy link
Member

I think you're probably right about it being PowerShell/PowerShellEditorServices#1823. /cc @SeeminglyScience

@andyleejordan
Copy link
Member

I'm having trouble reproducing this. Can you share more environment info? @SeeminglyScience sees it only after first causing an error in the PSIC, but neither of you mentioned this. I'm using PS 7.2.4 on macOS.

@andyleejordan
Copy link
Member

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

@cblackuk
Copy link

cblackuk commented Jun 23, 2022

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 :-)

@dbrennand
Copy link
Author

dbrennand commented Jun 23, 2022

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!"

@andyleejordan
Copy link
Member

Fix in PR!

@cblackuk
Copy link

That is so awesome :) thanks for such a quick turnaround :)

@dbrennand
Copy link
Author

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

@tropez1971
Copy link

Same issue, even running the latest PowerShell Preview v2022.6.2.

If this is fixed, how do I get my hands on it? Very annoying right now.

@pascalkrielen
Copy link

Same issue, noticed that when selecting text and hitting F8 the error occurs, when putting focus back on editor and running SAME lines with f8 it does not happen. When selecting other lines it happens again.

@andyleejordan andyleejordan changed the title Run selection with F8 causes executed code to be recalled into the integrated console prompt Run selection with F8 causes executed code to be recalled / duplicated into the integrated console prompt Jun 29, 2022
@andyleejordan
Copy link
Member

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

@cblackuk
Copy link

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 :-)

@dbrennand
Copy link
Author

dbrennand commented Jun 30, 2022

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

@andyleejordan
Copy link
Member

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

@cblackuk
Copy link

cblackuk commented Jul 1, 2022

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

@dbrennand
Copy link
Author

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

@tlgill
Copy link

tlgill commented Jul 1, 2022

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...

@andyleejordan
Copy link
Member

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 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

7 participants