@@ -13,8 +13,9 @@ import Settings = require('./settings');
13
13
14
14
import { Logger } from './logging' ;
15
15
import { IFeature } from './feature' ;
16
+ import { Message } from 'vscode-jsonrpc' ;
16
17
import { StringDecoder } from 'string_decoder' ;
17
- import { LanguageClient , LanguageClientOptions , Executable , RequestType , RequestType0 , NotificationType , StreamInfo } from 'vscode-languageclient' ;
18
+ import { LanguageClient , LanguageClientOptions , Executable , RequestType , RequestType0 , NotificationType , StreamInfo , ErrorAction , CloseAction } from 'vscode-languageclient' ;
18
19
19
20
export enum SessionStatus {
20
21
NotStarted ,
@@ -395,15 +396,13 @@ export class SessionManager {
395
396
396
397
vscode . window . onDidCloseTerminal (
397
398
terminal => {
398
- this . log . write ( os . EOL + "powershell.exe terminated or terminal UI was closed" + os . EOL ) ;
399
+ if ( terminal === this . consoleTerminal ) {
400
+ this . log . write ( os . EOL + "powershell.exe terminated or terminal UI was closed" + os . EOL ) ;
399
401
400
- if ( this . languageServerClient != undefined ) {
401
- this . languageServerClient . stop ( ) ;
402
- }
403
-
404
- if ( this . sessionStatus === SessionStatus . Running ) {
405
- this . setSessionStatus ( "Session exited" , SessionStatus . Failed ) ;
406
- this . promptForRestart ( ) ;
402
+ if ( this . sessionStatus === SessionStatus . Running ) {
403
+ this . setSessionStatus ( "Session exited" , SessionStatus . Failed ) ;
404
+ this . promptForRestart ( ) ;
405
+ }
407
406
}
408
407
} ) ;
409
408
@@ -459,6 +458,19 @@ export class SessionManager {
459
458
synchronize : {
460
459
configurationSection : utils . PowerShellLanguageId ,
461
460
//fileEvents: vscode.workspace.createFileSystemWatcher('**/.eslintrc')
461
+ } ,
462
+ errorHandler : {
463
+ // Override the default error handler to prevent it from
464
+ // closing the LanguageClient incorrectly when the socket
465
+ // hangs up (ECONNRESET errors).
466
+ error : ( error : any , message : Message , count : number ) : ErrorAction => {
467
+ // TODO: Is there any error worth terminating on?
468
+ return ErrorAction . Continue ;
469
+ } ,
470
+ closed : ( ) => {
471
+ // We have our own restart experience
472
+ return CloseAction . DoNotRestart
473
+ }
462
474
}
463
475
}
464
476
@@ -468,7 +480,6 @@ export class SessionManager {
468
480
connectFunc ,
469
481
clientOptions ) ;
470
482
471
-
472
483
this . languageServerClient . onReady ( ) . then (
473
484
( ) => {
474
485
this . languageServerClient
0 commit comments