From 0d3e539616967b5731fd8e80cc0637d389b65ae7 Mon Sep 17 00:00:00 2001 From: Garrett Campbell Date: Wed, 19 Jul 2023 16:27:49 -0400 Subject: [PATCH 1/3] fix per folder provide browse configuration We were returning the most recent stored browse configuration, which may be incorrect. Rather, we should return null if we don't have the browseConfiguration for the requested URI. --- CHANGELOG.md | 1 + src/cpptools.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b5b918a9..7d0d87be3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ 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) diff --git a/src/cpptools.ts b/src/cpptools.ts index f80fd6dad..0be32c513 100644 --- a/src/cpptools.ts +++ b/src/cpptools.ts @@ -401,8 +401,8 @@ export class CppConfigurationProvider implements cpptools.CustomConfigurationPro return true; } - async provideFolderBrowseConfiguration(uri: vscode.Uri): Promise { - return this.workspaceBrowseConfigurations.get(util.platformNormalizePath(uri.fsPath)) ?? this.workspaceBrowseConfiguration; + async provideFolderBrowseConfiguration(uri: vscode.Uri): Promise { + return this.workspaceBrowseConfigurations.get(util.platformNormalizePath(uri.fsPath)) ?? null; } /** No-op */ From e55df3e5f19750e09050de0366ecc9883b5a691b Mon Sep 17 00:00:00 2001 From: Garrett Campbell Date: Thu, 20 Jul 2023 09:53:58 -0400 Subject: [PATCH 2/3] fix test types --- test/unit-tests/cpptools.test.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/unit-tests/cpptools.test.ts b/test/unit-tests/cpptools.test.ts index 4a7d31e66..251949e3c 100644 --- a/test/unit-tests/cpptools.test.ts +++ b/test/unit-tests/cpptools.test.ts @@ -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 @@ -362,8 +362,8 @@ 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]); @@ -371,7 +371,7 @@ suite('CppTools tests', () => { 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)); }); }); From f66b88a14ffd7a0ee2d54a96c80c1dc3589a9d05 Mon Sep 17 00:00:00 2001 From: Garrett Campbell Date: Thu, 20 Jul 2023 09:55:03 -0400 Subject: [PATCH 3/3] edit changelog --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d0d87be3..0f010a6cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +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) +- 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