@@ -25,6 +25,9 @@ export class ClientCollection {
2525 private activeDocument ?: vscode . TextDocument ;
2626 public timeTelemetryCollector : TimeTelemetryCollector = new TimeTelemetryCollector ( ) ;
2727
28+ // This is a one-time switch to a mode that suppresses launching of the cpptools client process.
29+ private useFailsafeMode : boolean = false ;
30+
2831 public get ActiveClient ( ) : cpptools . Client { return this . activeClient ; }
2932 public get Names ( ) : ClientKey [ ] {
3033 const result : ClientKey [ ] = [ ] ;
@@ -104,22 +107,21 @@ export class ClientCollection {
104107 /**
105108 * creates a new client to replace one that crashed.
106109 */
107- public async recreateClients ( transferFileOwnership : boolean ) : Promise < void > {
110+ public async recreateClients ( switchToFailsafeMode ? : boolean ) : Promise < void > {
108111
109112 // Swap out the map, so we are not changing it while iterating over it.
110113 const oldLanguageClients : Map < string , cpptools . Client > = this . languageClients ;
111114 this . languageClients = new Map < string , cpptools . Client > ( ) ;
112115
116+ if ( switchToFailsafeMode ) {
117+ this . useFailsafeMode = true ;
118+ }
119+
113120 for ( const pair of oldLanguageClients ) {
114121 const client : cpptools . Client = pair [ 1 ] ;
115122
116- let newClient : cpptools . Client ;
117- if ( transferFileOwnership ) {
118- newClient = this . createClient ( client . RootFolder , true ) ;
119- client . TrackedDocuments . forEach ( document => this . transferOwnership ( document , client ) ) ;
120- } else {
121- newClient = cpptools . createNullClient ( ) ;
122- }
123+ const newClient : cpptools . Client = this . createClient ( client . RootFolder , true ) ;
124+ client . TrackedDocuments . forEach ( document => this . transferOwnership ( document , client ) ) ;
123125
124126 if ( this . activeClient === client ) {
125127 // It cannot be undefined. If there is an active document, we activate it later.
@@ -272,15 +274,14 @@ export class ClientCollection {
272274 }
273275
274276 public createClient ( folder ?: vscode . WorkspaceFolder , deactivated ?: boolean ) : cpptools . Client {
275- const newClient : cpptools . Client = cpptools . createClient ( this , folder ) ;
277+ const newClient : cpptools . Client = this . useFailsafeMode ? cpptools . createNullClient ( ) : cpptools . createClient ( this , folder ) ;
276278 if ( deactivated ) {
277279 newClient . deactivate ( ) ; // e.g. prevent the current config from switching.
278280 }
279281 const key : string = folder ? util . asFolder ( folder . uri ) : defaultClientKey ;
280282 this . languageClients . set ( key , newClient ) ;
281283 getCustomConfigProviders ( ) . forEach ( provider => newClient . onRegisterCustomConfigurationProvider ( provider ) ) ;
282- const defaultClient : cpptools . DefaultClient = < cpptools . DefaultClient > newClient ;
283- defaultClient . sendAllSettings ( ) ;
284+ newClient . sendAllSettings ( ) ;
284285 return newClient ;
285286 }
286287
0 commit comments