@@ -25,6 +25,9 @@ export class ClientCollection {
2525private activeDocument ?:vscode . TextDocument ;
2626public 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+
2831public get ActiveClient ( ) :cpptools . Client { return this . activeClient ; }
2932public get Names ( ) :ClientKey [ ] {
3033const 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.
110113const oldLanguageClients :Map < string , cpptools . Client > = this . languageClients ;
111114this . languageClients = new Map < string , cpptools . Client > ( ) ;
112115
116+ if ( switchToFailsafeMode ) {
117+ this . useFailsafeMode = true ;
118+ }
119+
113120for ( const pair of oldLanguageClients ) {
114121const 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
124126if ( 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
274276public 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 ) ;
276278if ( deactivated ) {
277279newClient . deactivate ( ) ; // e.g. prevent the current config from switching.
278280}
279281const key :string = folder ?util . asFolder ( folder . uri ) :defaultClientKey ;
280282this . languageClients . set ( key , newClient ) ;
281283getCustomConfigProviders ( ) . forEach ( provider => newClient . onRegisterCustomConfigurationProvider ( provider ) ) ;
282- const defaultClient :cpptools . DefaultClient = < cpptools . DefaultClient > newClient ;
283- defaultClient . sendAllSettings ( ) ;
284+ newClient . sendAllSettings ( ) ;
284285return newClient ;
285286}
286287