Skip to content

Commit b2b5424

Browse files
committed
implement show quick pick if no debug config selected
1 parent 9e8bca6 commit b2b5424

File tree

3 files changed

+73
-27
lines changed

3 files changed

+73
-27
lines changed

package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@
6363
"onLanguage:robotframework",
6464
"workspaceContains:**/*.{robot,resource}",
6565
"onDebug",
66+
"onDebugResolve:robotcode",
6667
"onDebugInitialConfigurations",
67-
"onDebugDynamicConfigurations",
68-
"onDebugResolve:robotcode"
68+
"onDebugDynamicConfigurations:robotcode"
69+
6970
],
7071
"galleryBanner": {
7172
"theme": "dark",
@@ -586,14 +587,14 @@
586587
},
587588
"initialConfigurations": [
588589
{
589-
"name": "RobotCode: Run .robot file",
590+
"name": "RobotCode: Run Current",
590591
"type": "robotcode",
591592
"request": "launch",
592593
"cwd": "${workspaceFolder}",
593594
"target": "${file}"
594595
},
595596
{
596-
"name": "RobotCode: Run all tests",
597+
"name": "RobotCode: Run All",
597598
"type": "robotcode",
598599
"request": "launch",
599600
"cwd": "${workspaceFolder}",
@@ -602,21 +603,21 @@
602603
],
603604
"configurationSnippets": [
604605
{
605-
"label": "RobotCode: Run .robot file",
606-
"description": "Add a new configuration for launching a single RobotFramework file.",
606+
"label": "RobotCode: Run Current",
607+
"description": "Run the current RobotFramework file.",
607608
"body": {
608-
"name": "RobotCode: Launch .robot file",
609+
"name": "RobotCode: Run Current",
609610
"type": "robotcode",
610611
"request": "launch",
611612
"cwd": "^\"\\${workspaceFolder}\"",
612613
"target": "^\"\\${file}\""
613614
}
614615
},
615616
{
616-
"label": "RobotCode: Run all tests",
617-
"description": "Add a new configuration for launching all RobotFramework tests.",
617+
"label": "RobotCode: Run All",
618+
"description": "Run all RobotFramework files.",
618619
"body": {
619-
"name": "RobotCode: Run all tests",
620+
"name": "RobotCode: Run All",
620621
"type": "robotcode",
621622
"request": "launch",
622623
"cwd": "^\"\\${workspaceFolder}\"",

vscode-client/debugmanager.ts

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,69 @@ import { WeakValueSet } from "./utils";
1111
const DEBUG_ADAPTER_DEFAULT_TCP_PORT = 6611;
1212
const DEBUG_ADAPTER_DEFAULT_HOST = "127.0.0.1";
1313

14+
const DEBUG_CONFIGURATIONS = [
15+
{
16+
label: "RobotCode: Run Current",
17+
description: "Run the current RobotFramework file.",
18+
body: {
19+
name: "RobotCode: Run Current",
20+
type: "robotcode",
21+
request: "launch",
22+
cwd: "${workspaceFolder}",
23+
target: "${file}",
24+
},
25+
},
26+
{
27+
label: "RobotCode: Run All",
28+
description: "Run all RobotFramework files.",
29+
body: {
30+
name: "RobotCode: Run All",
31+
type: "robotcode",
32+
request: "launch",
33+
cwd: "${workspaceFolder}",
34+
target: ".",
35+
},
36+
},
37+
];
38+
1439
class RobotCodeDebugConfigurationProvider implements vscode.DebugConfigurationProvider {
1540
constructor(private readonly pythonManager: PythonManager) {}
1641

42+
resolveDebugConfiguration(
43+
folder: vscode.WorkspaceFolder | undefined,
44+
debugConfiguration: vscode.DebugConfiguration,
45+
token?: vscode.CancellationToken
46+
): vscode.ProviderResult<vscode.DebugConfiguration> {
47+
return this._resolveDebugConfiguration(folder, debugConfiguration, token);
48+
}
49+
50+
// eslint-disable-next-line class-methods-use-this
51+
async _resolveDebugConfiguration(
52+
_folder: vscode.WorkspaceFolder | undefined,
53+
debugConfiguration: vscode.DebugConfiguration,
54+
token?: vscode.CancellationToken
55+
): Promise<vscode.DebugConfiguration> {
56+
if (!debugConfiguration.type && !debugConfiguration.request && !debugConfiguration.name) {
57+
const editor = vscode.window.activeTextEditor;
58+
if (editor && editor.document.languageId === "robotframework" && editor.document.fileName.endsWith(".robot")) {
59+
const result = await vscode.window.showQuickPick(
60+
DEBUG_CONFIGURATIONS.map((v) => v),
61+
{ canPickMany: false },
62+
token
63+
);
64+
65+
if (result !== undefined) {
66+
debugConfiguration = {
67+
...result?.body,
68+
...debugConfiguration,
69+
};
70+
}
71+
}
72+
}
73+
74+
return debugConfiguration;
75+
}
76+
1777
resolveDebugConfigurationWithSubstitutedVariables(
1878
folder: vscode.WorkspaceFolder | undefined,
1979
debugConfiguration: vscode.DebugConfiguration,
@@ -161,22 +221,7 @@ export class DebugManager {
161221
_folder: vscode.WorkspaceFolder | undefined,
162222
_token?: vscode.CancellationToken
163223
): vscode.ProviderResult<vscode.DebugConfiguration[]> {
164-
return [
165-
{
166-
name: "RobotCode: Run .robot file",
167-
type: "robotcode",
168-
request: "launch",
169-
cwd: "${workspaceFolder}",
170-
target: "${file}",
171-
},
172-
{
173-
name: "RobotCode: Run all tests",
174-
type: "robotcode",
175-
request: "launch",
176-
cwd: "${workspaceFolder}",
177-
target: ".",
178-
},
179-
];
224+
return DEBUG_CONFIGURATIONS.map((v) => v.body);
180225
},
181226
},
182227
vscode.DebugConfigurationProviderTriggerKind.Dynamic

vscode-client/testcontrollermanager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class TestControllerManager {
111111
}
112112
}
113113
}),
114-
vscode.workspace.onDidCloseTextDocument(async (document) => {
114+
vscode.workspace.onDidCloseTextDocument((document) => {
115115
this.refreshDocument(document);
116116
}),
117117
vscode.workspace.onDidSaveTextDocument((document) => {

0 commit comments

Comments
 (0)