diff --git a/CHANGELOG.md b/CHANGELOG.md index 98f7cfe2..bd05a467 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ Bug Fixes: - Quote launch arguments sent to the terminal if they have special characters. [#2898](https://github.com/microsoft/vscode-cmake-tools/issues/2898) - CMake Tools should choose cmake.exe from the newest VS when it's not found in the PATH. [#2753](https://github.com/microsoft/vscode-cmake-tools/issues/2753) - Calling build targets from CMake Project Outline always builds default target if useTasks option is set. [#2778](https://github.com/microsoft/vscode-cmake-tools/issues/2768) [@piomis]](https://github.com/piomis) +- Fix a problem with multi-root projects not activating the configuration provider. [#2915](https://github.com/microsoft/vscode-cmake-tools/issues/2915) - Remove the default path for `cmake.mingwSearchDirs` since the path is world-writable. [PR #2942](https://github.com/microsoft/vscode-cmake-tools/pull/2942) - Build command is not able to properly pick-up tasks from tasks.json file if configured with isDefault option and cancellation of running build task is not working. [#2935](https://github.com/microsoft/vscode-cmake-tools/issues/2935) [@piomis]](https://github.com/piomis) diff --git a/src/cpptools.ts b/src/cpptools.ts index e378bfbc..f80fd6da 100644 --- a/src/cpptools.ts +++ b/src/cpptools.ts @@ -639,9 +639,12 @@ export class CppConfigurationProvider implements cpptools.CustomConfigurationPro this.lastUpdateSucceeded = !hadMissingCompilers; } - private ready: boolean = false; + private readyFlag: boolean = false; + get ready(): boolean { + return this.readyFlag; + } markAsReady() { - this.ready = true; + this.readyFlag = true; } getDiagnostics(): DiagnosticsCpptools { @@ -666,7 +669,7 @@ export class CppConfigurationProvider implements cpptools.CustomConfigurationPro } return { - isReady: this.ready, + isReady: this.readyFlag, hasCodeModel: this.fileIndex.size > 0, activeBuildType: this.activeBuildType || "", buildTypesSeen: [...this.buildTypesSeen.values()], diff --git a/src/extension.ts b/src/extension.ts index 2a7303d9..a5aec351 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -589,7 +589,6 @@ export class ExtensionManager implements vscode.Disposable { } } - private cpptoolsNumFoldersReady: number = 0; private updateCodeModel(cmakeProject?: CMakeProject) { if (!cmakeProject) { return; @@ -674,17 +673,19 @@ export class ExtensionManager implements vscode.Disposable { } // Inform cpptools that custom CppConfigurationProvider will be able to service the current workspace. this.ensureCppToolsProviderRegistered(); - if (cpptools.notifyReady && this.cpptoolsNumFoldersReady < this.projectController.numOfWorkspaceFolders) { - ++this.cpptoolsNumFoldersReady; - if (this.cpptoolsNumFoldersReady === this.projectController.numOfWorkspaceFolders) { - // Notify cpptools that the provider is ready to provide IntelliSense configurations. - cpptools.notifyReady(this.configProvider); - this.configProvider.markAsReady(); - } - } else { + if (this.configProvider.ready) { + // TODO: Make this smarter and only notify when there are changes to files that have been requested by cpptools already. cpptools.didChangeCustomBrowseConfiguration(this.configProvider); cpptools.didChangeCustomConfiguration(this.configProvider); + } else { this.configProvider.markAsReady(); + if (cpptools.notifyReady) { + // Notify cpptools that the provider is ready to provide IntelliSense configurations. + cpptools.notifyReady(this.configProvider); + } else { + cpptools.didChangeCustomBrowseConfiguration(this.configProvider); + cpptools.didChangeCustomConfiguration(this.configProvider); + } } } }); diff --git a/src/projectController.ts b/src/projectController.ts index 6702b5ee..5d3ce96d 100644 --- a/src/projectController.ts +++ b/src/projectController.ts @@ -113,6 +113,14 @@ export class ProjectController implements vscode.Disposable { return this.getAllCMakeProjects().length; } + async getNumOfValidProjects(): Promise { + let count: number = 0; + for (const project of this.getAllCMakeProjects()) { + count += (await project.hasCMakeLists() ? 1 : 0); + } + return count; + } + get hasMultipleProjects(): boolean { return this.numOfProjects > 1; }