Fix configProvider activation for multi-root (#2943)

This commit is contained in:
Bob Brown 2023-01-12 14:17:07 -08:00 коммит произвёл GitHub
Родитель e80038f65d
Коммит 15f2518532
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 25 добавлений и 12 удалений

Просмотреть файл

@ -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)

Просмотреть файл

@ -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()],

Просмотреть файл

@ -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);
}
}
}
});

Просмотреть файл

@ -113,6 +113,14 @@ export class ProjectController implements vscode.Disposable {
return this.getAllCMakeProjects().length;
}
async getNumOfValidProjects(): Promise<number> {
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;
}