Skip to content

Commit 06fefa7

Browse files
committed
implement DebugConfigurationProvider
Without this, ee19751 doesn't seem to do anything useful
1 parent 8fa9488 commit 06fefa7

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/extension.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export function activate(context: vscode.ExtensionContext): void {
3636

3737
ev3devBrowserProvider = new Ev3devBrowserProvider();
3838
const factory = new Ev3devDebugAdapterDescriptorFactory();
39+
const provider = new Ev3devDebugConfigurationProvider();
3940
context.subscriptions.push(
4041
output, ev3devBrowserProvider,
4142
vscode.window.registerTreeDataProvider('ev3devBrowser', ev3devBrowserProvider),
@@ -57,6 +58,7 @@ export function activate(context: vscode.ExtensionContext): void {
5758
vscode.commands.registerCommand('ev3devBrowser.action.refresh', () => refresh()),
5859
vscode.debug.onDidReceiveDebugSessionCustomEvent(e => handleCustomDebugEvent(e)),
5960
vscode.debug.registerDebugAdapterDescriptorFactory('ev3devBrowser', factory),
61+
vscode.debug.registerDebugConfigurationProvider('ev3devBrowser', provider),
6062
);
6163
}
6264

@@ -82,6 +84,45 @@ class Ev3devDebugAdapterDescriptorFactory implements vscode.DebugAdapterDescript
8284
}
8385
}
8486

87+
class Ev3devDebugConfigurationProvider implements vscode.DebugConfigurationProvider {
88+
async resolveDebugConfiguration(
89+
_folder: vscode.WorkspaceFolder | undefined,
90+
debugConfiguration: vscode.DebugConfiguration,
91+
token?: vscode.CancellationToken,
92+
): Promise<vscode.DebugConfiguration | undefined> {
93+
if (Object.keys(debugConfiguration).length === 0) {
94+
type DebugConfigurationQuickPickItem = vscode.QuickPickItem & { interactiveTerminal: boolean };
95+
const items: DebugConfigurationQuickPickItem[] = [
96+
{
97+
label: "Download and run current file",
98+
description: "in interactive terminal",
99+
interactiveTerminal: true,
100+
},
101+
{
102+
label: "Download and run current file",
103+
description: "in output pane",
104+
interactiveTerminal: false,
105+
},
106+
];
107+
const selected = await vscode.window.showQuickPick(items, {
108+
matchOnDescription: true,
109+
ignoreFocusOut: true,
110+
placeHolder: "Debug configuration"
111+
}, token);
112+
if (selected) {
113+
return {
114+
type: "ev3devBrowser",
115+
name: `${selected.label} ${selected.description}`,
116+
request: "launch",
117+
program: "/home/robot/${workspaceFolderBasename}/${relativeFile}",
118+
interactiveTerminal: selected.interactiveTerminal
119+
};
120+
}
121+
}
122+
return undefined;
123+
}
124+
}
125+
85126
// this method is called when your extension is deactivated
86127
export function deactivate(): void {
87128
// The "temp" module should clean up automatically, but do this just in case.

0 commit comments

Comments
 (0)