Skip to content

Commit feb8a64

Browse files
Make Play Button available to all users (#9311)
1 parent bf2674f commit feb8a64

File tree

4 files changed

+17
-26
lines changed

4 files changed

+17
-26
lines changed

Extension/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2662,10 +2662,7 @@
26622662
},
26632663
"C_Cpp.debugShortcut": {
26642664
"type": "boolean",
2665-
"default": false,
2666-
"tags": [
2667-
"experimental"
2668-
],
2665+
"default": true,
26692666
"description": "%c_cpp.configuration.debugShortcut.description%",
26702667
"scope": "application"
26712668
},

Extension/package.nls.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@
222222
"c_cpp.configuration.legacyCompilerArgsBehavior.deprecationMessage": "This setting is temporary to support transitioning to corrected behavior in v1.10.0.",
223223
"c_cpp.contributes.views.cppReferencesView.title": "C/C++: Other references results",
224224
"c_cpp.contributes.viewsWelcome.contents": { "message": "To learn more about launch.json, see [Configuring C/C++ debugging](https://code.visualstudio.com/docs/cpp/launch-json-reference).", "comment": [ "Markdown text between () should not be altered: https://en.wikipedia.org/wiki/Markdown" ] },
225-
"c_cpp.configuration.debugShortcut.description": "Show the Run and Debug play button in the editor title bar for C++ files.",
225+
"c_cpp.configuration.debugShortcut.description": "Show the \"Run and Debug\" play button and \"Add Debug Configuration\" gear in the editor title bar for C++ files.",
226226
"c_cpp.debuggers.pipeTransport.description": "When present, this tells the debugger to connect to a remote computer using another executable as a pipe that will relay standard input/output between VS Code and the MI-enabled debugger backend executable (such as gdb).",
227227
"c_cpp.debuggers.pipeTransport.default.pipeProgram": "enter the fully qualified path for the pipe program name, for example '/usr/bin/ssh'.",
228228
"c_cpp.debuggers.pipeTransport.default.debuggerPath": "The full path to the debugger on the target machine, for example /usr/bin/gdb.",

Extension/src/Debugger/configurationProvider.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,8 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
125125
}
126126

127127
const items: MenuItem[] = configs.map<MenuItem>(config => {
128-
const reducedConfig: vscode.DebugConfiguration = {...config};
129-
// Remove the extra properties that are not a part of the DebugConfiguration.
130-
reducedConfig.detail = undefined;
131-
reducedConfig.existing = undefined;
132-
reducedConfig.isDefault = undefined;
133-
const menuItem: MenuItem = { label: config.name, configuration: reducedConfig, description: config.detail, detail: config.existing };
128+
const quickPickConfig: vscode.DebugConfiguration = {...config};
129+
const menuItem: MenuItem = { label: config.name, configuration: quickPickConfig, description: config.detail, detail: config.existing };
134130
// Rename the menu item for the default configuration as its name is non-descriptive.
135131
if (isDebugLaunchStr(menuItem.label)) {
136132
menuItem.label = localize("default.configuration.menuitem", "Default Configuration");
@@ -148,6 +144,10 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
148144
this.showErrorIfClNotAvailable(selection.label);
149145
}
150146

147+
// Remove the extra properties that are not a part of the DebugConfiguration, as these properties will be written in launch.json.
148+
selection.configuration.detail = undefined;
149+
selection.configuration.existing = undefined;
150+
selection.configuration.isDefault = undefined;
151151
return [selection.configuration];
152152
}
153153

@@ -665,7 +665,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
665665
if (!folder) {
666666
return;
667667
}
668-
const selectedConfig: vscode.DebugConfiguration | undefined = await this.selectConfiguration(textEditor, true);
668+
const selectedConfig: vscode.DebugConfiguration | undefined = await this.selectConfiguration(textEditor, false);
669669
if (!selectedConfig) {
670670
Telemetry.logDebuggerEvent(DebuggerEvent.launchPlayButton, { "debugType": "AddConfigurationOnly", "folderMode": folder ? "folder" : "singleFile", "cancelled": "true" });
671671
return; // User canceled it.
@@ -751,7 +751,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
751751
if (configuration.preLaunchTask) {
752752
try {
753753
if (folder) {
754-
await cppBuildTaskProvider.writeBuildTask(configuration.preLaunchTask);
754+
await cppBuildTaskProvider.writeDefaultBuildTask(configuration.preLaunchTask);
755755
} else {
756756
// In case of singleFile, remove the preLaunch task from the debug configuration and run it here instead.
757757
await cppBuildTaskProvider.runBuildTask(configuration.preLaunchTask);

Extension/src/LanguageServer/cppBuildTaskProvider.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,25 +227,19 @@ export class CppBuildTaskProvider implements TaskProvider {
227227
}
228228

229229
public async writeDefaultBuildTask(taskLabel: string): Promise<void> {
230-
return this.checkBuildTaskExists(taskLabel, true, true);
230+
return this.writeBuildTask(taskLabel, true);
231231
}
232232

233-
public async writeBuildTask(taskLabel: string): Promise<void> {
234-
return this.checkBuildTaskExists(taskLabel, true);
235-
}
236-
237-
public async checkBuildTaskExists(taskLabel: string, createTask: boolean = false, setAsDefault: boolean = false): Promise<void> {
233+
public async writeBuildTask(taskLabel: string, setAsDefault: boolean = false): Promise<void> {
238234
const rawTasksJson: any = await this.getRawTasksJson();
239235
if (!rawTasksJson.tasks) {
240236
rawTasksJson.tasks = new Array();
241237
}
242-
// Ensure that the task exists in the user's task.json. Task will not be found otherwise.
238+
// Check if the task exists in the user's task.json.
243239
let selectedTask: any;
244-
if (!createTask) {
245-
selectedTask = rawTasksJson.tasks.find((task: any) => task.label && task.label === taskLabel);
246-
if (selectedTask) {
247-
return;
248-
}
240+
selectedTask = rawTasksJson.tasks.find((task: any) => task.label && task.label === taskLabel);
241+
if (selectedTask) {
242+
return;
249243
}
250244

251245
// Create the task which should be created based on the selected "debug configuration".
@@ -261,7 +255,7 @@ export class CppBuildTaskProvider implements TaskProvider {
261255
}
262256
rawTasksJson.version = "2.0.0";
263257

264-
// Modify the current default task
258+
// If the new task should be set as the default task, modify the current default task.
265259
if (setAsDefault) {
266260
rawTasksJson.tasks.forEach((task: any) => {
267261
if (task.label === selectedTask?.definition.label) {

0 commit comments

Comments
 (0)