File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,10 @@ export class PowerShellProcess {
163
163
}
164
164
}
165
165
166
+ public sendKeyPress ( ) {
167
+ this . consoleTerminal . sendText ( "\0" , false ) ;
168
+ }
169
+
166
170
private logTerminalPid ( pid : number , exeName : string ) {
167
171
this . log . write ( `${ exeName } PID: ${ pid } ` ) ;
168
172
}
Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ export enum SessionStatus {
34
34
Failed ,
35
35
}
36
36
37
+ export const SendKeyPressNotificationType =
38
+ new NotificationType < void > ( "powerShell/sendKeyPress" ) ;
39
+
37
40
export class SessionManager implements Middleware {
38
41
public HostName : string ;
39
42
public HostVersion : string ;
@@ -605,6 +608,14 @@ export class SessionManager implements Middleware {
605
608
this . languageServerClient . onNotification (
606
609
RunspaceChangedEventType ,
607
610
( 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 ( ) ; } ) ;
608
619
} ,
609
620
( reason ) => {
610
621
this . setSessionFailure ( "Could not start language service: " , reason ) ;
You can’t perform that action at this time.
0 commit comments