Skip to content

Commit e8d0ded

Browse files
authored
Fix for null ref race condition when using custom config providers. (#3377)
* Fix for null ref race condition when using custom config providers.
1 parent f5bdac9 commit e8d0ded

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Extension/src/LanguageServer/client.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -319,16 +319,6 @@ class DefaultClient implements Client {
319319
this.configuration.CompileCommandsChanged((e) => this.onCompileCommandsChanged(e));
320320
this.disposables.push(this.configuration);
321321

322-
// The configurations will not be sent to the language server until the default include paths and frameworks have been set.
323-
// The event handlers must be set before this happens.
324-
languageClient.sendRequest(QueryCompilerDefaultsRequest, {}).then((compilerDefaults: configs.CompilerDefaults) => {
325-
this.configuration.CompilerDefaults = compilerDefaults;
326-
327-
// Only register the real commands after the extension has finished initializing,
328-
// e.g. prevents empty c_cpp_properties.json from generation.
329-
registerCommands();
330-
});
331-
332322
this.languageClient = languageClient;
333323
this.settingsTracker = getTracker(this.RootUri);
334324
telemetry.logLanguageServerEvent("NonDefaultInitialCppSettings", this.settingsTracker.getUserModifiedSettings());
@@ -337,6 +327,16 @@ class DefaultClient implements Client {
337327
// Listen for messages from the language server.
338328
this.registerNotifications();
339329
this.registerFileWatcher();
330+
331+
// The configurations will not be sent to the language server until the default include paths and frameworks have been set.
332+
// The event handlers must be set before this happens.
333+
return languageClient.sendRequest(QueryCompilerDefaultsRequest, {}).then((compilerDefaults: configs.CompilerDefaults) => {
334+
this.configuration.CompilerDefaults = compilerDefaults;
335+
336+
// Only register the real commands after the extension has finished initializing,
337+
// e.g. prevents empty c_cpp_properties.json from generation.
338+
registerCommands();
339+
});
340340
},
341341
(err) => {
342342
this.isSupported = false; // Running on an OS we don't support yet.

0 commit comments

Comments
 (0)