You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PSReadline char @ is added in the output of all scripts #2274
So I've done some debugging here and it looks like our API with PSReadLine isn't quite right.
Here is where we implement our own version of Console.ReadLine() which we can cancel so as to run PowerShell commands for things like completions in the background.
Currently, when it cancels, it sends back default(ConsoleKeyInfo) to PSReadLine. This is effectively as NUL char ('\0'). I suspect that either PSReadLine or xtermjs turns that into an @.
I played with turning it into a space, returning new ConsoleKeyInfo(' ', ConsoleKey.Spacebar, shift: false, alt: false, control: false). It's not perfect, but it's a lot less problematic than @.
Short term, we should find a character that is as helpful as possible that we can return here.
Medium term, we should work with Dongbo Wang (@daxian-dbw) to change the way we interact with PSReadLine either to make this bool TryReadKey(out ConsoleKeyInfo cki) (or with a nullable), or look into idle eventing (Dongbo Wang (@daxian-dbw)'s suggestion) for running commands behind the prompt.
Give this VSIX a try and let me know if it solves things. Przemysław Kłys (@PrzemyslawKlys) I'm particularly interested in whether it solves any of your other bugs.
I suspect we need to update our PSRL load logic -- the issue is that we need something in a particular beta version (and PSRL's version scheme combined with the module system's support for prerelease versions makes life hard)
Here is the script we use to find PSReadLine, which specifically drops beta2.
It may be that the PSConsoleReadLine type is already loaded from the wrong PSRL at that point in some cases. PSRL's versioning makes this hard for us unfortunately.
It seems to be related to how you handle prompt. It seems you "add" your own prompt with PSReadLine, when it's already added.
Yes that's probably us renewing the prompt improperly. We already fudge the prompt correctly in a number of cases, it just doesn't look like it. We can continue that discussion in #2276 if that's alright. Just want to keep the discussions separate (primarily so I don't get confused).
Activity
bgelens commentedon Nov 4, 2019
I have a similar thing. F8 for run selection will insert
@on the new prompt after running the selectionTylerLeonhardt commentedon Nov 4, 2019
Yes this seems to be an issue in PSReadLine. I'm investigating it and can repro
TylerLeonhardt commentedon Nov 4, 2019
Thankfully, the
@in the prompt does not impact F8'ing code so you can still do that even if there's a@(or anything really) sitting in your promptbgelens commentedon Nov 4, 2019
True. They do stack up though :)
TylerLeonhardt commentedon Nov 4, 2019
This was introduced in PowerShell/PowerShellEditorServices#1072
What's the saying? "1 bug fixed, 2 more appear"? 😅
rjmholt commentedon Nov 4, 2019
/cc Dongbo Wang (@daxian-dbw)
rjmholt commentedon Nov 4, 2019
So I've done some debugging here and it looks like our API with PSReadLine isn't quite right.
Here is where we implement our own version of
Console.ReadLine()which we can cancel so as to run PowerShell commands for things like completions in the background.Currently, when it cancels, it sends back
default(ConsoleKeyInfo)to PSReadLine. This is effectively asNULchar ('\0'). I suspect that either PSReadLine or xtermjs turns that into an@.I played with turning it into a space, returning
new ConsoleKeyInfo(' ', ConsoleKey.Spacebar, shift: false, alt: false, control: false). It's not perfect, but it's a lot less problematic than@.Short term, we should find a character that is as helpful as possible that we can return here.
Medium term, we should work with Dongbo Wang (@daxian-dbw) to change the way we interact with PSReadLine either to make this
bool TryReadKey(out ConsoleKeyInfo cki)(or with a nullable), or look into idle eventing (Dongbo Wang (@daxian-dbw)'s suggestion) for running commands behind the prompt.rjmholt commentedon Nov 4, 2019
Give this VSIX a try and let me know if it solves things. Przemysław Kłys (@PrzemyslawKlys) I'm particularly interested in whether it solves any of your other bugs.
psvsix.zip
bgelens commentedon Nov 5, 2019
Rob Holt (@rjmholt) That fixes it for me!
PrzemyslawKlys commentedon Nov 5, 2019
That's what I get after installing and running this extension. So I guess PSReadLine is not working :-)
3 remaining items
TylerLeonhardt commentedon Nov 5, 2019
Sorry I need the prerelease version.
Should be in there.
PrzemyslawKlys commentedon Nov 5, 2019
TylerLeonhardt commentedon Nov 5, 2019
One last thing:
Or if you use vscode insiders:
PrzemyslawKlys commentedon Nov 5, 2019
TylerLeonhardt commentedon Nov 5, 2019
Ok the problem here is that we're not loading the correct PSReadLine.
rjmholt commentedon Nov 5, 2019
Try
Install-Module -Force PSReadLine -AllowPrelease-- that should put a newer PSReadLine earlier on your pathrjmholt commentedon Nov 5, 2019
I suspect we need to update our PSRL load logic -- the issue is that we need something in a particular beta version (and PSRL's version scheme combined with the module system's support for prerelease versions makes life hard)
PrzemyslawKlys commentedon Nov 6, 2019
So that fix works but still the other problem is there:
PrzemyslawKlys commentedon Nov 6, 2019
It seems to be related to how you handle prompt. It seems you "add" your own prompt with PSReadLine, when it's already added.
if I use something like this:
The output will be:
But then if you press Enter it will bring proper prompt back. So either you have to skip adding your own prompt or overwrite the original one.
rjmholt commentedon Nov 6, 2019
Here is the script we use to find PSReadLine, which specifically drops
beta2.It may be that the
PSConsoleReadLinetype is already loaded from the wrong PSRL at that point in some cases. PSRL's versioning makes this hard for us unfortunately.rjmholt commentedon Nov 6, 2019
Yes that's probably us renewing the prompt improperly. We already fudge the prompt correctly in a number of cases, it just doesn't look like it. We can continue that discussion in #2276 if that's alright. Just want to keep the discussions separate (primarily so I don't get confused).
PrzemyslawKlys commentedon Nov 6, 2019
Just to add, installing the new .vsix on another machine:
It seems like the VSIX (the one .zipped) is missing some paths.
Not sure what is missing on my home machine.