File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,10 @@ export class PowerShellProcess {
163163 }
164164 }
165165
166+ public sendKeyPress ( ) {
167+ this . consoleTerminal . sendText ( "\0" , false ) ;
168+ }
169+
166170 private logTerminalPid ( pid : number , exeName : string ) {
167171 this . log . write ( `${ exeName } PID: ${ pid } ` ) ;
168172 }
Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ export enum SessionStatus {
3434 Failed ,
3535}
3636
37+ export const SendKeyPressNotificationType =
38+ new NotificationType < void > ( "powerShell/sendKeyPress" ) ;
39+
3740export class SessionManager implements Middleware {
3841 public HostName : string ;
3942 public HostVersion : string ;
@@ -605,6 +608,14 @@ export class SessionManager implements Middleware {
605608 this . languageServerClient . onNotification (
606609 RunspaceChangedEventType ,
607610 ( runspaceDetails ) => { this . setStatusBarVersionString ( runspaceDetails ) ; } ) ;
611+
612+ // NOTE: This fixes a quirk where PSES has a thread stuck on
613+ // Console.ReadKey, since it's not cancellable. On
614+ // "cancellation" the server asks us to send pretend to
615+ // press a key, thus mitigating all the quirk.
616+ this . languageServerClient . onNotification (
617+ SendKeyPressNotificationType ,
618+ ( ) => { this . languageServerProcess . sendKeyPress ( ) ; } ) ;
608619 } ,
609620 ( reason ) => {
610621 this . setSessionFailure ( "Could not start language service: " , reason ) ;
You can’t perform that action at this time.
0 commit comments