@@ -25,6 +25,9 @@ export class ClientCollection {
25
25
private activeDocument ?: vscode . TextDocument ;
26
26
public timeTelemetryCollector : TimeTelemetryCollector = new TimeTelemetryCollector ( ) ;
27
27
28
+ // This is a one-time switch to a mode that suppresses launching of the cpptools client process.
29
+ private useFailsafeMode : boolean = false ;
30
+
28
31
public get ActiveClient ( ) : cpptools . Client { return this . activeClient ; }
29
32
public get Names ( ) : ClientKey [ ] {
30
33
const result : ClientKey [ ] = [ ] ;
@@ -104,22 +107,21 @@ export class ClientCollection {
104
107
/**
105
108
* creates a new client to replace one that crashed.
106
109
*/
107
- public async recreateClients ( transferFileOwnership : boolean ) : Promise < void > {
110
+ public async recreateClients ( switchToFailsafeMode ? : boolean ) : Promise < void > {
108
111
109
112
// Swap out the map, so we are not changing it while iterating over it.
110
113
const oldLanguageClients : Map < string , cpptools . Client > = this . languageClients ;
111
114
this . languageClients = new Map < string , cpptools . Client > ( ) ;
112
115
116
+ if ( switchToFailsafeMode ) {
117
+ this . useFailsafeMode = true ;
118
+ }
119
+
113
120
for ( const pair of oldLanguageClients ) {
114
121
const client : cpptools . Client = pair [ 1 ] ;
115
122
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 ) ) ;
123
125
124
126
if ( this . activeClient === client ) {
125
127
// It cannot be undefined. If there is an active document, we activate it later.
@@ -272,15 +274,14 @@ export class ClientCollection {
272
274
}
273
275
274
276
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 ) ;
276
278
if ( deactivated ) {
277
279
newClient . deactivate ( ) ; // e.g. prevent the current config from switching.
278
280
}
279
281
const key : string = folder ? util . asFolder ( folder . uri ) : defaultClientKey ;
280
282
this . languageClients . set ( key , newClient ) ;
281
283
getCustomConfigProviders ( ) . forEach ( provider => newClient . onRegisterCustomConfigurationProvider ( provider ) ) ;
282
- const defaultClient : cpptools . DefaultClient = < cpptools . DefaultClient > newClient ;
283
- defaultClient . sendAllSettings ( ) ;
284
+ newClient . sendAllSettings ( ) ;
284
285
return newClient ;
285
286
}
286
287
0 commit comments