Skip to content

Commit

Permalink
feat: easy Electron app picker when starting C++ debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
dsanders11 committed Jan 30, 2025
1 parent 9cdaea7 commit 1a61d5d
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 4 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
"type": "cppvsdbg",
"request": "launch",
"program": "${command:electron-build-tools.show.exec}",
"args": [],
"args": ["${command:electron-build-tools.debug.showOpenDialog}"],
"stopAtEntry": false,
"cwd": "${command:electron-build-tools.show.root}\\src",
"environment": [
Expand Down Expand Up @@ -305,9 +305,9 @@
"type": "cppdbg",
"request": "launch",
"program": "${command:electron-build-tools.show.exec}",
"args": [],
"args": ["${command:electron-build-tools.debug.showOpenDialog}"],
"stopAtEntry": false,
"cwd": "${command:electron-build-tools.show.root}/src",
"cwd": "${workspaceFolder}",
"environment": [
{
"name": "ELECTRON_ENABLE_LOGGING",
Expand All @@ -327,7 +327,7 @@
"setupCommands": [
{
"description": "Run Chromium lldbinit.py",
"text": "command script import ${cwd}/tools/lldb/lldbinit.py"
"text": "command script import ${command:electron-build-tools.show.root}/src/tools/lldb/lldbinit.py"
}
],
"sourceFileMap": {
Expand Down
56 changes: 56 additions & 0 deletions src/commands/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as vscode from "vscode";
import MarkdownIt from "markdown-it";
import wrap from "word-wrap";

import { commandPrefix } from "../constants";
import Logger from "../logging";

enum MarkdownTableColumnAlignment {
Expand Down Expand Up @@ -99,6 +100,61 @@ export function registerHelperCommands(context: vscode.ExtensionContext) {
}
},
),
vscode.commands.registerCommand(
`${commandPrefix}.debug.showOpenDialog`,
async () => {
const selection = await vscode.window.showQuickPick(
[
{
label: "Default Electron App",
iconPath: {
dark: vscode.Uri.joinPath(
context.extensionUri,
"resources",
"icons",
"dark",
"electron.svg",
),
light: vscode.Uri.joinPath(
context.extensionUri,
"resources",
"icons",
"light",
"electron.svg",
),
},
detail: "The default Electron app",
},
{
label: "Custom Electron App",
iconPath: new vscode.ThemeIcon("folder-opened"),
detail: "Select a local path to an Electron app",
},
{
label: "URL",
iconPath: new vscode.ThemeIcon("globe"),
detail: "Enter a URL starting with http(s)://",
},
],
{ placeHolder: "Select Electron app to run, or run the default app" },
);

if (selection?.label === "Custom Electron App") {
return (
await vscode.window.showOpenDialog({
canSelectFiles: true,
canSelectFolders: true,
})
)?.[0].fsPath;
} else if (selection?.label === "URL") {
return await vscode.window.showInputBox({
placeHolder: "Enter a URL starting with http(s)://",
});
}

return "";
},
),
vscode.commands.registerTextEditorCommand(
"markdown.prettifyTable",
(textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit) => {
Expand Down

0 comments on commit 1a61d5d

Please sign in to comment.