Skip to content

Canceling prompt is not possible in preview extension #3876

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

Closed
5 tasks done
PrzemyslawKlys opened this issue Mar 15, 2022 · 34 comments
Closed
5 tasks done

Canceling prompt is not possible in preview extension #3876

PrzemyslawKlys opened this issue Mar 15, 2022 · 34 comments
Assignees
Labels
Area-Extension Terminal Issue-Bug A bug to squash. Resolution-External Will close automatically.

Comments

@PrzemyslawKlys
Copy link
Contributor

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.

Summary

When you use mandatory parameters and it prompts you to enter value it's impossible to cancel it with CTRL+C or SHIFT+F5. You need to go thru the whole process and then it stops.

function Test-Me {
    [cmdletBinding()]
    param(
        [Parameter(Mandatory = $true)] $Test
    )
}

Test-Me

Same thing applies to Read-Host

PowerShell Version

Name                           Value
----                           -----
PSVersion                      5.1.22000.282
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22000.282
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Visual Studio Code Version

1.65.2
c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1
x64

Extension Version

Steps to Reproduce

  1. Run any command that has mandatory parameters
  2. Try to cancel it
  3. Alternatively try with Read-Host
  4. Try to cancel it

Visuals

No response

Logs

No response

@PrzemyslawKlys PrzemyslawKlys added the Issue-Bug A bug to squash. label Mar 15, 2022
@ghost ghost added the Needs: Triage Maintainer attention needed! label Mar 15, 2022
@andyleejordan andyleejordan added Area-Extension Terminal and removed Needs: Triage Maintainer attention needed! labels Mar 15, 2022
@andyleejordan andyleejordan self-assigned this Mar 15, 2022
@andyleejordan andyleejordan moved this to Todo in Sea Biscuit Mar 15, 2022
@andyleejordan
Copy link
Member

Thanks @PrzemyslawKlys! I'm planning to look into this tomorrow.

@andyleejordan
Copy link
Member

andyleejordan commented Mar 17, 2022

This is not reproducing for me with PowerShell 7.2 on neither macOS nor Windows 11.

@andyleejordan
Copy link
Member

Hm, it's also not reproducing with Windows PowerShell 5.1 for me either.

@andyleejordan
Copy link
Member

Yeah, I can't repro this at all. Not with the latest released preview (nor master) on Windows nor Mac with 5.1 nor 7.2, neither running Test-Me in the IC by itself nor from running it via F5 in the script, even with a breakpoint set.

Can you find a more specific way to repro this?

@andyleejordan andyleejordan moved this from Todo to In Progress in Sea Biscuit Mar 17, 2022
@andyleejordan
Copy link
Member

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.22000.282
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22000.282
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

@andyleejordan
Copy link
Member

Funny thing though: executing Read-Host directly in the IC just loops into a PSReadLine stacktrace over and over, but that's a separate bug 😆

@PrzemyslawKlys
Copy link
Contributor Author

For me, I can reproduce CTRL+C every single time. And Shift+F5 requires at least 2 enters to get out of it.

CtrlC example:
CtrlC

Read Host example:
ReadHost

@andyleejordan
Copy link
Member

@PrzemyslawKlys Can you test this build?
powershell-preview-2022.3.0.vsix.zip It has commit PowerShell/PowerShellEditorServices@4cadd73 which I want to see the effects of...

@PrzemyslawKlys
Copy link
Contributor Author

It doesn't work :)

image

image

@PrzemyslawKlys
Copy link
Contributor Author

Weirdly enough I cannot use the old preview anymore, i have to go back 3 weeks and use the 3 weeks old version. Otherwise I get this whenever i try to update to newest version (not even your version).

image

I've broken something ;)

@andyleejordan
Copy link
Member

Ok, I have no idea what's happened to your environment there, oops 😅 but I tried again, on Windows with PS 5.1 too, and can always Ctrl-C to cancel Test-Me. @SeeminglyScience You said you were able to repro this?

@andyleejordan
Copy link
Member

I still can't repro this at all. How up-to-date is your Windows environment @PrzemyslawKlys, and is this a major blocker for you?

@PrzemyslawKlys
Copy link
Contributor Author

PrzemyslawKlys commented Mar 24, 2022

I'm on cutting edge Windows 11 ;) It's not a blocker at all. Lately, I'm really enjoying the plugin and its features. don't have to restart, everything seems to work. This is one of those things that shows up, but I know I can just press CTRL+C, and a few times enter and it will work ;)

I typed the command, it prompted - i typed text ... pressed CTRL+C, it didn't work, I pressed enter - and as you see below it didn't assign the value to anything.

image

That means CTRL+C actually worked, but I think it's related to other issue that sometimes you need to press ENTER to see the prompt when the script is "done". It may be just visual bug.

@andyleejordan
Copy link
Member

It's strange, for sure, and I want to get it fixed. Thank you for the kind words, we're really working on launching this soon to the stable channel. We know it's not perfect, but are increasingly convinced that it's much better than it was. Preparing hopefully the second-to-last preview right now!

@andyleejordan
Copy link
Member

Ok, it's a long shot, but does this continue to repro with the new release yesterday? v2022.3.1-preview.

@PrzemyslawKlys
Copy link
Contributor Author

PrzemyslawKlys commented Mar 25, 2022

Nothing changed (as in I can still repro it). But maybe it's related to the version of the module (PSReadLine?)?

image

@andyleejordan
Copy link
Member

Hm, 2.2.2 is the latest. I wish I could repro this myself 🥲

@PrzemyslawKlys
Copy link
Contributor Author

If you need any logs I can provide ;) If you need any other help - i'm here...

@andyleejordan
Copy link
Member

Hi there, we just released v2022.4.0-preview! Could you please try PowerShell Preview for VS Code and check if this is fixed? I could still never repro it myself, but I implemented what I hope to be a much better way to cancel Console.ReadKey and so avoid deadlocks like this.

@andyleejordan andyleejordan added the Needs: Fix Verification Please verify the fix for us! label Apr 12, 2022
@andyleejordan andyleejordan moved this from Punted to In Progress in Sea Biscuit Apr 12, 2022
@PrzemyslawKlys
Copy link
Contributor Author

No luck ;)

Didnthelp

@andyleejordan
Copy link
Member

Dumb question, but what about other terminals in Code, or other PowerShell versions? At this point I feel like there's something configured in Code that's taken that key handler, and I still can't repro 😭 Underneath the covers, it really is just Console.ReadKey now!

@PrzemyslawKlys
Copy link
Contributor Author

You're correct. If I paste Read-Host into a separate terminal in code it acts the same. So the big question is - how to track it ;)

@andyleejordan andyleejordan moved this from In Progress to Wishlist in Sea Biscuit Apr 13, 2022
@andyleejordan andyleejordan moved this from Wishlist to Punted in Sea Biscuit Apr 13, 2022
@andyleejordan
Copy link
Member

AH! I hate to do this to you...but file a bug with Code.

@andyleejordan andyleejordan added Resolution-External Will close automatically. and removed Needs: Fix Verification Please verify the fix for us! labels Apr 13, 2022
@andyleejordan andyleejordan moved this from Punted to Done in Sea Biscuit Apr 13, 2022
@andyleejordan
Copy link
Member

Just be very clear that it repros in standard PowerShell terminals in VS Code, no extension required!

@PrzemyslawKlys
Copy link
Contributor Author

PrzemyslawKlys commented Apr 13, 2022

But it doesn't repro for you... so maybe some of my settings is affecting this.

@SeeminglyScience
Copy link
Collaborator

But it doesn't repro for you... so maybe some of my settings is affecting this.

Try enabling Developer: Toggle Keyboard Shortcuts Troubleshooting, selecting the terminal panel, pressing Ctrl + C and the go back to Output. See what you have there

Here's mine for instance:

image

@PrzemyslawKlys
Copy link
Contributor Author

image
image

@SeeminglyScience
Copy link
Collaborator

What about "terminal.integrated.windowsEnableConpty": true, you got that on?

@SeeminglyScience
Copy link
Collaborator

Also the original issue says 5.1, can you check if 7 has the same behavior?

@PrzemyslawKlys
Copy link
Contributor Author

I have it disabled "terminal.integrated.windowsEnableConpty": false, after enabling it ---> IT WORKS!

@PrzemyslawKlys
Copy link
Contributor Author

I had it disabled based on: #2377

@SeeminglyScience
Copy link
Collaborator

WOOT

Yeah conpty solves a lot of input related issues. Even when that bug was still going I just grit my teeth through it as it's fixes were worth the very frustrating bug. I forgot all about that... that was rough 😁

@PrzemyslawKlys
Copy link
Contributor Author

Thank you guys! Sorry for this false bug report.

@andyleejordan
Copy link
Member

It wasn't false! Something was buggy, and I'm glad @SeeminglyScience knew what was up, woo 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Extension Terminal Issue-Bug A bug to squash. Resolution-External Will close automatically.
Projects
No open projects
Status: Done
Development

No branches or pull requests

3 participants