Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix per folder provide browse configuration #3249

Merged
merged 3 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ Features:

Bug Fixes:
- When using CMake presets, the Project Status View now shows the build target along with the build preset. [PR #3241](https://github.com/microsoft/vscode-cmake-tools/pull/3241)
- Fix per-folder browse configurations returning incorrect information. [#3155](https://github.com/microsoft/vscode-cmake-tools/issues/3155)

Improvements:
- Decreased the number of cases where we reconfigure erroneously upon usage of `cmake.getLaunchTargetPath` [#2878](https://github.com/microsoft/vscode-cmake-tools/issues/2878)
- Fix our checking for invalid settings when CMakeUserPresets version is different than CMakePresets [#2897](https://github.com/microsoft/vscode-cmake-tools/issues/2897)
- Decreased the number of cases where we reconfigure erroneously upon usage of `cmake.getLaunchTargetPath`. [#2878](https://github.com/microsoft/vscode-cmake-tools/issues/2878)
- Fix our checking for invalid settings when CMakeUserPresets version is different than CMakePresets. [#2897](https://github.com/microsoft/vscode-cmake-tools/issues/2897)
- Fix the precendence order that we evaluate the `cmake.parallelJobs` setting. [#3206](https://github.com/microsoft/vscode-cmake-tools/issues/3206)

## 1.14.33
Expand Down
4 changes: 2 additions & 2 deletions src/cpptools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ export class CppConfigurationProvider implements cpptools.CustomConfigurationPro
return true;
}

async provideFolderBrowseConfiguration(uri: vscode.Uri): Promise<cpptools.WorkspaceBrowseConfiguration> {
return this.workspaceBrowseConfigurations.get(util.platformNormalizePath(uri.fsPath)) ?? this.workspaceBrowseConfiguration;
async provideFolderBrowseConfiguration(uri: vscode.Uri): Promise<cpptools.WorkspaceBrowseConfiguration | null> {
return this.workspaceBrowseConfigurations.get(util.platformNormalizePath(uri.fsPath)) ?? null;
}

/** No-op */
Expand Down
16 changes: 8 additions & 8 deletions test/unit-tests/cpptools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,16 @@ suite('CppTools tests', () => {
const canProvideBrowseConfigPerFolder: boolean = await provider.canProvideBrowseConfigurationsPerFolder();
expect(canProvideBrowseConfigPerFolder).to.eq(true);
const browseConfig = await provider.provideFolderBrowseConfiguration(vscode.Uri.file(here));
expect(browseConfig.browsePath.length).to.eq(1);
expect(browseConfig.browsePath[0]).to.eq(util.platformNormalizePath(here));
expect(browseConfig?.browsePath.length).to.eq(1);
expect(browseConfig?.browsePath[0]).to.eq(util.platformNormalizePath(here));

// Verify the browsePath with a different folder.
const configurations2 = await provider.provideConfigurations([uri3]);
expect(configurations2.length).to.eq(1);
expect(configurations2[0].configuration.defines).to.contain('FLAG3');
const browseConfig2 = await provider.provideFolderBrowseConfiguration(vscode.Uri.file(smokeFolder));
expect(browseConfig2.browsePath.length).to.eq(1);
expect(browseConfig2.browsePath[0]).to.eq(util.platformNormalizePath(smokeFolder));
expect(browseConfig2?.browsePath.length).to.eq(1);
expect(browseConfig2?.browsePath[0]).to.eq(util.platformNormalizePath(smokeFolder));
});

// Validate codeModel using cppTools API V6
Expand Down Expand Up @@ -362,16 +362,16 @@ suite('CppTools tests', () => {
const canProvideBrowseConfigPerFolder: boolean = await provider.canProvideBrowseConfigurationsPerFolder();
expect(canProvideBrowseConfigPerFolder).to.eq(true);
const browseConfig = await provider.provideFolderBrowseConfiguration(vscode.Uri.file(here));
expect(browseConfig.browsePath.length).to.eq(1);
expect(browseConfig.browsePath[0]).to.eq(util.platformNormalizePath(here));
expect(browseConfig?.browsePath.length).to.eq(1);
expect(browseConfig?.browsePath[0]).to.eq(util.platformNormalizePath(here));

// Verify the browsePath with a different folder.
const configurations2 = await provider.provideConfigurations([uri3]);
expect(configurations2.length).to.eq(1);
expect(configurations2[0].configuration.defines).to.be.empty;
expect(configurations2[0].configuration.compilerFragments).to.contain('-DFRAGMENT3');
const browseConfig2 = await provider.provideFolderBrowseConfiguration(vscode.Uri.file(smokeFolder));
expect(browseConfig2.browsePath.length).to.eq(1);
expect(browseConfig2.browsePath[0]).to.eq(util.platformNormalizePath(smokeFolder));
expect(browseConfig2?.browsePath.length).to.eq(1);
expect(browseConfig2?.browsePath[0]).to.eq(util.platformNormalizePath(smokeFolder));
});
});