Skip to content

Commit 1a61d5d

Browse files
committed
feat: easy Electron app picker when starting C++ debugger
1 parent 9cdaea7 commit 1a61d5d

File tree

2 files changed

+60
-4
lines changed

2 files changed

+60
-4
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
"type": "cppvsdbg",
274274
"request": "launch",
275275
"program": "${command:electron-build-tools.show.exec}",
276-
"args": [],
276+
"args": ["${command:electron-build-tools.debug.showOpenDialog}"],
277277
"stopAtEntry": false,
278278
"cwd": "${command:electron-build-tools.show.root}\\src",
279279
"environment": [
@@ -305,9 +305,9 @@
305305
"type": "cppdbg",
306306
"request": "launch",
307307
"program": "${command:electron-build-tools.show.exec}",
308-
"args": [],
308+
"args": ["${command:electron-build-tools.debug.showOpenDialog}"],
309309
"stopAtEntry": false,
310-
"cwd": "${command:electron-build-tools.show.root}/src",
310+
"cwd": "${workspaceFolder}",
311311
"environment": [
312312
{
313313
"name": "ELECTRON_ENABLE_LOGGING",
@@ -327,7 +327,7 @@
327327
"setupCommands": [
328328
{
329329
"description": "Run Chromium lldbinit.py",
330-
"text": "command script import ${cwd}/tools/lldb/lldbinit.py"
330+
"text": "command script import ${command:electron-build-tools.show.root}/src/tools/lldb/lldbinit.py"
331331
}
332332
],
333333
"sourceFileMap": {

src/commands/helpers.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as vscode from "vscode";
33
import MarkdownIt from "markdown-it";
44
import wrap from "word-wrap";
55

6+
import { commandPrefix } from "../constants";
67
import Logger from "../logging";
78

89
enum MarkdownTableColumnAlignment {
@@ -99,6 +100,61 @@ export function registerHelperCommands(context: vscode.ExtensionContext) {
99100
}
100101
},
101102
),
103+
vscode.commands.registerCommand(
104+
`${commandPrefix}.debug.showOpenDialog`,
105+
async () => {
106+
const selection = await vscode.window.showQuickPick(
107+
[
108+
{
109+
label: "Default Electron App",
110+
iconPath: {
111+
dark: vscode.Uri.joinPath(
112+
context.extensionUri,
113+
"resources",
114+
"icons",
115+
"dark",
116+
"electron.svg",
117+
),
118+
light: vscode.Uri.joinPath(
119+
context.extensionUri,
120+
"resources",
121+
"icons",
122+
"light",
123+
"electron.svg",
124+
),
125+
},
126+
detail: "The default Electron app",
127+
},
128+
{
129+
label: "Custom Electron App",
130+
iconPath: new vscode.ThemeIcon("folder-opened"),
131+
detail: "Select a local path to an Electron app",
132+
},
133+
{
134+
label: "URL",
135+
iconPath: new vscode.ThemeIcon("globe"),
136+
detail: "Enter a URL starting with http(s)://",
137+
},
138+
],
139+
{ placeHolder: "Select Electron app to run, or run the default app" },
140+
);
141+
142+
if (selection?.label === "Custom Electron App") {
143+
return (
144+
await vscode.window.showOpenDialog({
145+
canSelectFiles: true,
146+
canSelectFolders: true,
147+
})
148+
)?.[0].fsPath;
149+
} else if (selection?.label === "URL") {
150+
return await vscode.window.showInputBox({
151+
placeHolder: "Enter a URL starting with http(s)://",
152+
});
153+
}
154+
155+
return "";
156+
},
157+
),
102158
vscode.commands.registerTextEditorCommand(
103159
"markdown.prettifyTable",
104160
(textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit) => {

0 commit comments

Comments
 (0)