vscode-powershell icon indicating copy to clipboard operation
vscode-powershell copied to clipboard

2.0.0-insiders-834: prompt gets displayed in an endless loop

Open sba923 opened this issue 8 years ago • 68 comments

Issue Description

When I open a folder containing PowerShell scripts, the integrated terminal displays the prompt in an endless loop, as if I would press and hold the Enter key for it to autorepeat.

Attached Logs

See 1539111398-a60423be-01d3-4cc1-83df-f15ead97e8aa1539111394598.zip

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 10.0.17763
VSCode 1.28.0
PowerShell Extension Version 2.0.0-insiders-834

PowerShell Information

Name Value
PSVersion 5.1.17763.1
PSEdition Desktop
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.17763.1
BuildVersion 10.0.17763.1
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)
Extension Author Version
beautify HookyQR 1.4.4
cpptools ms-vscode 0.19.0
csharp ms-vscode 1.16.2
path-intellisense christian-kohler 1.4.2
PowerShell ms-vscode 2.0.0-insiders-834
prettier-vscode esbenp 1.6.1
printcode nobuhito 3.0.0
vscode-color anseki 0.4.5
vscode-html-css ecmel 0.2.0
vscode-javascript-snippet-pack akamud 0.1.5
vscode-npm-script eg2 0.3.5
vscode-standardjs chenxsan 1.2.3
vscode-tidyhtml anweber 1.10.0

sba923 avatar Oct 10 '18 04:10 sba923

Well... I must've done something... now even in Windows PowerShell 5.1 I don't get syntax coloring anymore either...

How do I repair that?

(I know, that's somewhat off-topic, but linked to experimenting with versions of PSReadLine in relationship to the present issue...)

sba923 avatar Jan 23 '19 06:01 sba923

      We'll have an official preview release this week that will be installable from the extension marketplace.

I hate to say, but the endless loop is still there with that preview...

sba923 avatar Jan 25 '19 06:01 sba923

I've also encountered the endless prompt loop.

rkeithhill avatar Jan 25 '19 16:01 rkeithhill

Where do we go from here?

sba923 avatar Jan 27 '19 12:01 sba923

What could I do to help fix that?

sba923 avatar Feb 01 '19 05:02 sba923

IMVHO this is a showstopper for version 2.0 of the PowerShell extension for VScode. How can I help getting this resolved?

sba923 avatar Mar 08 '19 06:03 sba923

It is a showstopper for v2.0. We just haven't had a chance to look at the issue yet. I promise we'll address it before release of 2.0!

What would help is providing any information as to what you're doing when the endless loop occurs

TylerLeonhardt avatar Mar 11 '19 22:03 TylerLeonhardt

Is there anything I can do to help? What would be the setup and tools required to debug this?

sba923 avatar Mar 12 '19 18:03 sba923

I think just use the Preview build, and when you hit the endless loop, let us know (in as much detail as possible) what you were doing when you hit it.

TylerLeonhardt avatar Mar 12 '19 22:03 TylerLeonhardt

@TylerLeonhardt I have the same problem (endless loop) on my setup :

  • VS Code PowerShell Preview
  • PSReadline 2.0.0 beta 3
  • French Keyboard

My Workaround at the moment is to :

  • change keyboard layout to US (from system tray)
  • launch VS Code
  • change keyboard layout to FR

fMichaleczek avatar Mar 14 '19 13:03 fMichaleczek

I try to update to :

  • last CI VSCode-PowerShell
  • last CI PSReadLine

The problem is still here.

fMichaleczek avatar Mar 14 '19 14:03 fMichaleczek

It happened to me this morning just after restarting vscode insiders to install ~the latest~ yesterday's insiders. It happens so seldom that I often don't notice it for a bit and then just hit the trash can and relaunch the extension with no problem :shrug:

corbob avatar Mar 14 '19 17:03 corbob

I think just use the Preview build, and when you hit the endless loop, let us know (in as much detail as possible) what you were doing when you hit it.

Well... I'm not doing anything special ;-)

But to be more specific here are steps guaranteed to end up with the endless loop (when the preview of the extension is enabled, of course):

  1. Start VSCode with no folder or file opened
  2. Open a folder with at least one PowerShell script in it
  3. Open the PowerShell script
  4. at this point, the TERMINAL pane shows my PowerShell profile script executing, which ends up with a prompt being displayed... in an endless loop.

I confirm that @fmichaleczek's workaround works.

How can we help further?

sba923 avatar Mar 16 '19 06:03 sba923

Important note about the workaround: every time you switch to another workspace, or do anything where the TERMINAL starts a new PowerShell instance, you have to switch to the US keyboard layout and then back to the French layout.

sba923 avatar Mar 16 '19 07:03 sba923

@sba923 Yes, it's annoying.

The problem is localized after the profile processing script ... so i made a small helper :

Microsoft.VSCode_profile.ps1

$languageToInvert = "fr-FR", "en-US"
$waitInMs = 1500
Set-WinUserLanguageList -LanguageList $LanguageToInvert[1], $LanguageToInvert[0] -Force 
$timer = [System.Timers.Timer]@{ Interval = $waitInMs }
Register-ObjectEvent -InputObject $Timer -EventName Elapsed -SourceIdentifier Timer -Action {
    Set-WinUserLanguageList -LanguageList $LanguageToInvert[0], $LanguageToInvert[1] -Force
    $timer.Stop() ; Unregister-Event Timer ; Remove-Variable languageToInvert, waitSec, timer
} > $null
$timer.Start()

fMichaleczek avatar Mar 17 '19 14:03 fMichaleczek

Does this also work if the "VScode PowerShell host" is restarted e.g. after each debugging session?

sba923 avatar Mar 17 '19 15:03 sba923

Yes, the profile script is launched each time the extension is loaded or reloaded. I added an event timer to switch back keyboard to french after some milliseconds.

fMichaleczek avatar Mar 17 '19 15:03 fMichaleczek

This works like a charm, thx a zillion.

Of course, that doesn't remove my offer to help with fixing the issue!

sba923 avatar Mar 18 '19 08:03 sba923

Hi all, I have some (potentially) good news. This seems to be an issue in PSReadLine itself and it will be fixed in this PR:

https://github.com/lzybkr/PSReadLine/pull/831

Once that's in, we wait for a release of PSRL, and then we can bundle that with the extension.

TylerLeonhardt avatar Mar 18 '19 17:03 TylerLeonhardt

IIRC we've known for some time that the issue is in PSRL. Glad that they are tackling it at last.

sba923 avatar Mar 18 '19 20:03 sba923