-
Notifications
You must be signed in to change notification settings - Fork 311
Respect cancellation in ReadOneOrMoreKeys()
#3274
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
Conversation
@daxian-dbw do you know of any scenarios where Like, this is the entry point for PowerShell itself: PSReadLine/PSReadLine/ReadLine.cs Lines 318 to 328 in f46f15d
And PSReadLine/PSReadLine/ReadLine.cs Line 43 in f46f15d
Which doesn't look like it ever gets canceled (except maybe on disposal). (Also, why isn't it just literally Soo with the note here: PSReadLine/PSReadLine/ReadLine.cs Lines 330 to 339 in f46f15d
This makes me think that PSES is quite possibly the only "custom PSHost implementations that require the ability to cancel ReadLine." Which would mean this is quite a safe change for a v2.2.3? |
Basically because
It's the only one I know of (I mean, it's why I added the API in the first place) but it was purposefully designed as a public API as I can imagine other scenarios. That said, it's pretty unlikely anyone else is using it unless @daxian-dbw happens to know of someone. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with a couple comments.
I don't know of any other scenario where the |
Because .NET's . `Console.ReadKey()` is uncancellable, when a hosting application cancels PSReadLine, it also has to send a key press to get `ReadKey` to return. In this case, we want to ignore the key press (and a user certainly would not be expecting it, as `ReadLine` has already been canceled).
7640159
to
3487a13
Compare
Thanks @daxian-dbw! Do you think we could get a 2.2.3 release this week? |
Yeah, we can do a 2.2.3 release this week. |
Because .NET's .
Console.ReadKey()
is uncancellable, when a hosting application cancels PSReadLine, it also has to send a key press to getReadKey
to return. In this case, we want to ignore the key press (and a user certainly would not be expecting it, asReadLine
has already been canceled).This fixes PowerShell/PowerShellEditorServices#1754, at least as tested on Windows and macOS with PowerShell 7.
Microsoft Reviewers: Open in CodeFlow