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

only set isUserPreset to true if it's defined in a user presets file #4081

Merged
merged 5 commits into from
Oct 10, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Features:

Bug Fixes:

- Fix our setting of `isUserPreset` for presets, only set it to `true` if it's defined in a user presets file. [#4059](https://github.com/microsoft/vscode-cmake-tools/issues/4059)
- Fix issue where duplicate presets are being listed in dropdown. [#4104](https://github.com/microsoft/vscode-cmake-tools/issues/4104)

## 1.19.52
Expand Down
41 changes: 20 additions & 21 deletions src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,24 +467,39 @@ export function setPresetsPlusIncluded(folder: string, presets: PresetsFile | un
presetsPlusIncluded.set(folder, presets);
}

export function setUserPresetsPlusIncluded(folder: string, presets: PresetsFile | undefined) {
export function setUserPresetsHelper(presets: PresetsFile | undefined) {
snehara99 marked this conversation as resolved.
Show resolved Hide resolved
if (presets) {
// for each condition of `isUserPreset`, if we don't find file.path, then we default to true like before.
if (presets.configurePresets) {
for (const configPreset of presets.configurePresets) {
configPreset.isUserPreset = true;
configPreset.isUserPreset = configPreset.__file?.__path?.endsWith("CMakeUserPresets.json") ?? true;
}
}
if (presets.buildPresets) {
for (const buildPreset of presets.buildPresets) {
buildPreset.isUserPreset = true;
buildPreset.isUserPreset = buildPreset.__file?.__path?.endsWith("CMakeUserPresets.json") ?? true;
}
}
if (presets.testPresets) {
for (const testPreset of presets.testPresets) {
testPreset.isUserPreset = true;
testPreset.isUserPreset = testPreset.__file?.__path?.endsWith("CMakeUserPresets.json") ?? true;
}
}
if (presets.packagePresets) {
for (const packagePreset of presets.packagePresets) {
packagePreset.isUserPreset = packagePreset.__file?.__path?.endsWith("CMakeUserPresets.json") ?? true;
}
}
if (presets.workflowPresets) {
for (const workflowPreset of presets.workflowPresets) {
workflowPreset.isUserPreset = workflowPreset.__file?.__path?.endsWith("CMakeUserPresets.json") ?? true;
}
}
}
}

export function setUserPresetsPlusIncluded(folder: string, presets: PresetsFile | undefined) {
setUserPresetsHelper(presets);
userPresetsPlusIncluded.set(folder, presets);
}

Expand Down Expand Up @@ -544,23 +559,7 @@ function updateCachedExpandedPresethelper(cache: PresetsFile | undefined, preset
}

export function setExpandedUserPresetsFile(folder: string, presets: PresetsFile | undefined) {
if (presets) {
if (presets.configurePresets) {
for (const configPreset of presets.configurePresets) {
configPreset.isUserPreset = true;
}
}
if (presets.buildPresets) {
for (const buildPreset of presets.buildPresets) {
buildPreset.isUserPreset = true;
}
}
if (presets.testPresets) {
for (const testPreset of presets.testPresets) {
testPreset.isUserPreset = true;
}
}
}
setUserPresetsHelper(presets);
expandedUserPresets.set(folder, presets);
}

Expand Down
Loading