Make Play Button available to all users (#9311)

This commit is contained in:
Elaheh Rashedi
2022-05-19 13:45:15 -07:00
committed by GitHub
parent bf2674fd0c
commit feb8a6421a
4 changed files with 17 additions and 26 deletions
+1 -4
View File
@@ -2662,10 +2662,7 @@
},
"C_Cpp.debugShortcut": {
"type": "boolean",
"default": false,
"tags": [
"experimental"
],
"default": true,
"description": "%c_cpp.configuration.debugShortcut.description%",
"scope": "application"
},
+1 -1
View File
@@ -222,7 +222,7 @@
"c_cpp.configuration.legacyCompilerArgsBehavior.deprecationMessage": "This setting is temporary to support transitioning to corrected behavior in v1.10.0.",
"c_cpp.contributes.views.cppReferencesView.title": "C/C++: Other references results",
"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" ] },
"c_cpp.configuration.debugShortcut.description": "Show the Run and Debug play button in the editor title bar for C++ files.",
"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.",
"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).",
"c_cpp.debuggers.pipeTransport.default.pipeProgram": "enter the fully qualified path for the pipe program name, for example '/usr/bin/ssh'.",
"c_cpp.debuggers.pipeTransport.default.debuggerPath": "The full path to the debugger on the target machine, for example /usr/bin/gdb.",
@@ -125,12 +125,8 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
}
const items: MenuItem[] = configs.map<MenuItem>(config => {
const reducedConfig: vscode.DebugConfiguration = {...config};
// Remove the extra properties that are not a part of the DebugConfiguration.
reducedConfig.detail = undefined;
reducedConfig.existing = undefined;
reducedConfig.isDefault = undefined;
const menuItem: MenuItem = { label: config.name, configuration: reducedConfig, description: config.detail, detail: config.existing };
const quickPickConfig: vscode.DebugConfiguration = {...config};
const menuItem: MenuItem = { label: config.name, configuration: quickPickConfig, description: config.detail, detail: config.existing };
// Rename the menu item for the default configuration as its name is non-descriptive.
if (isDebugLaunchStr(menuItem.label)) {
menuItem.label = localize("default.configuration.menuitem", "Default Configuration");
@@ -148,6 +144,10 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
this.showErrorIfClNotAvailable(selection.label);
}
// Remove the extra properties that are not a part of the DebugConfiguration, as these properties will be written in launch.json.
selection.configuration.detail = undefined;
selection.configuration.existing = undefined;
selection.configuration.isDefault = undefined;
return [selection.configuration];
}
@@ -665,7 +665,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
if (!folder) {
return;
}
const selectedConfig: vscode.DebugConfiguration | undefined = await this.selectConfiguration(textEditor, true);
const selectedConfig: vscode.DebugConfiguration | undefined = await this.selectConfiguration(textEditor, false);
if (!selectedConfig) {
Telemetry.logDebuggerEvent(DebuggerEvent.launchPlayButton, { "debugType": "AddConfigurationOnly", "folderMode": folder ? "folder" : "singleFile", "cancelled": "true" });
return; // User canceled it.
@@ -751,7 +751,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
if (configuration.preLaunchTask) {
try {
if (folder) {
await cppBuildTaskProvider.writeBuildTask(configuration.preLaunchTask);
await cppBuildTaskProvider.writeDefaultBuildTask(configuration.preLaunchTask);
} else {
// In case of singleFile, remove the preLaunch task from the debug configuration and run it here instead.
await cppBuildTaskProvider.runBuildTask(configuration.preLaunchTask);
@@ -227,25 +227,19 @@ export class CppBuildTaskProvider implements TaskProvider {
}
public async writeDefaultBuildTask(taskLabel: string): Promise<void> {
return this.checkBuildTaskExists(taskLabel, true, true);
return this.writeBuildTask(taskLabel, true);
}
public async writeBuildTask(taskLabel: string): Promise<void> {
return this.checkBuildTaskExists(taskLabel, true);
}
public async checkBuildTaskExists(taskLabel: string, createTask: boolean = false, setAsDefault: boolean = false): Promise<void> {
public async writeBuildTask(taskLabel: string, setAsDefault: boolean = false): Promise<void> {
const rawTasksJson: any = await this.getRawTasksJson();
if (!rawTasksJson.tasks) {
rawTasksJson.tasks = new Array();
}
// Ensure that the task exists in the user's task.json. Task will not be found otherwise.
// Check if the task exists in the user's task.json.
let selectedTask: any;
if (!createTask) {
selectedTask = rawTasksJson.tasks.find((task: any) => task.label && task.label === taskLabel);
if (selectedTask) {
return;
}
selectedTask = rawTasksJson.tasks.find((task: any) => task.label && task.label === taskLabel);
if (selectedTask) {
return;
}
// Create the task which should be created based on the selected "debug configuration".
@@ -261,7 +255,7 @@ export class CppBuildTaskProvider implements TaskProvider {
}
rawTasksJson.version = "2.0.0";
// Modify the current default task
// If the new task should be set as the default task, modify the current default task.
if (setAsDefault) {
rawTasksJson.tasks.forEach((task: any) => {
if (task.label === selectedTask?.definition.label) {