Skip to content

Commit 5281786

Browse files
committed
Address PR feedback
1 parent 80c9d8e commit 5281786

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Extension/src/Debugger/configurationProvider.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
8787
const defaultConfig: CppDebugConfiguration[] = this.findDefaultConfig(configs);
8888
// If there was only one config defined for the default task, choose that config, otherwise ask the user to choose.
8989
if (defaultConfig.length === 1) {
90+
if (this.isClConfiguration(defaultConfig[0].name) && await this.showErrorIfClNotAvailable(defaultConfig[0].label)) {
91+
return []; // Cannot continue with build/debug.
92+
}
9093
return defaultConfig;
9194
}
9295

@@ -120,8 +123,8 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
120123
return []; // User canceled it.
121124
}
122125

123-
if (this.isClConfiguration(selection.label)) {
124-
await this.showErrorIfClNotAvailable(selection.label);
126+
if (this.isClConfiguration(selection.label) && await this.showErrorIfClNotAvailable(selection.label)) {
127+
return []; // Cannot continue with build/debug.
125128
}
126129

127130
return [selection.configuration];
@@ -578,8 +581,8 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
578581
return `${localize("build.and.debug.active.file", 'build and debug active file')}`;
579582
}
580583

581-
private isClConfiguration(configurationLabel: string): boolean {
582-
return configurationLabel.startsWith("C/C++: cl.exe");
584+
private isClConfiguration(configurationLabel?: string): boolean {
585+
return !!configurationLabel?.startsWith("C/C++: cl.exe");
583586
}
584587

585588
/**
@@ -606,7 +609,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
606609
// Ignore the error, the user will be prompted to apply the environment manually.
607610
}
608611
}
609-
if (response === cancel) {
612+
if (response === cancel || response === undefined) {
610613
// A message was already shown, so exit early noting that the environment is not available. We don't need to show another error message.
611614
return true;
612615
}
@@ -615,7 +618,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
615618
return false;
616619
}
617620
void vscode.window.showErrorMessage(
618-
localize('dev.env.not.applied', 'The Visual Studio Developer Environment was not applied. Please try again or run VS Code from the Developer Command Prompt for VS.'));
621+
localize('dev.env.not.applied', 'The source code could not be built because the Visual Studio Developer Environment was not applied.'));
619622
return true;
620623
}
621624

Extension/src/LanguageServer/cppBuildTaskProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ export class CppBuildTaskProvider implements TaskProvider {
246246
const cppBuildTask: CppBuildTask = new Task(definition, TaskScope.Workspace, task.label, ext.CppSourceStr);
247247
cppBuildTask.detail = task.detail;
248248
cppBuildTask.existing = true;
249-
if (task.group.isDefault) {
249+
if (util.isObject(task.group) && task.group.isDefault) {
250250
cppBuildTask.isDefault = true;
251251
}
252252
return cppBuildTask;

0 commit comments

Comments
 (0)