Skip to content

Commit 81d0744

Browse files
committed
Fix Issue #4421 - always clean rebuild
1 parent 51b7ced commit 81d0744

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Bug Fixes:
4040
- Fix bug that shows empty lines in Pinned Commands view. [#4406](https://github.com/microsoft/vscode-cmake-tools/issues/4406)
4141
- Fix Compiler Warnings not shown in Problems Window [#4567]https://github.com/microsoft/vscode-cmake-tools/issues/4567
4242
- Fix bug in which clicking "Run Test" for filtered tests executed all tests instead [#4501](https://github.com/microsoft/vscode-cmake-tools/pull/4501) [@hippo91](https://github.com/hippo91)
43+
- Fix bug in which running "CMake: Build" would always run "CMake: Clean Rebuild" when `cmake.buildTask` is enabled [#4421](https://github.com/microsoft/vscode-cmake-tools/issues/4421) [@RedSkittleFox](https://github.com/RedSkittleFox)
4344

4445
## 1.20.53
4546

src/cmakeTaskProvider.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,15 @@ export class CMakeTaskProvider implements vscode.TaskProvider {
328328
if (defaultTask.length >= 1) {
329329
return defaultTask[0];
330330
} else {
331+
// If there are two tasks, both of them are templates, either build or clean rebuild, select the build one - the first one
332+
if (matchingTargetTasks.length === 2) {
333+
return matchingTargetTasks[0];
334+
}
331335
// If there is no default task, matchingTargetTasks is a mixture of template and defined tasks.
332336
// If there is only one task, that task is a template, so return the template.
333-
// If there are only two tasks, the first one is always a template, and the second one is the defined task that we are searching for.
334-
// But if there are more than two tasks, it means that there are multiple defiend tasks and none are set as default. So ask the user to choose one later.
335-
if (matchingTargetTasks.length === 1 || matchingTargetTasks.length === 2) {
337+
// If there are three tasks, the first two are always templates, and the third one is the defined task that we are searching for.
338+
// But if there are more than three tasks, it means that there are multiple defiend tasks and none are set as default. So ask the user to choose one later.
339+
if (matchingTargetTasks.length === 1 || matchingTargetTasks.length === 3) {
336340
return matchingTargetTasks[matchingTargetTasks.length - 1];
337341
}
338342
}
@@ -451,14 +455,14 @@ export class CustomBuildTaskTerminal extends proc.CommandConsumer implements vsc
451455
void vscode.window.showErrorMessage(
452456
localize('task.not.compatible.with.preset.setting', 'The selected task requests a CMakePreset, but the workspace is not configured for CMakePresets'),
453457
change, ignore).then((selection) => {
454-
if (selection === change) {
455-
const config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration();
456-
if (config) {
457-
const newValue: UseCMakePresets = (presetDefined) ? 'always' : 'never';
458-
void config.update("cmake.useCMakePresets", newValue);
458+
if (selection === change) {
459+
const config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration();
460+
if (config) {
461+
const newValue: UseCMakePresets = (presetDefined) ? 'always' : 'never';
462+
void config.update("cmake.useCMakePresets", newValue);
463+
}
459464
}
460-
}
461-
});
465+
});
462466
this.writeEmitter.fire(localize('task.not.compatible.with.preset.setting', 'The selected task is not compatible with preset setting.') + endOfLine);
463467
this.closeEmitter.fire(-1);
464468
return false;

0 commit comments

Comments
 (0)