aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands/runnables.ts
diff options
context:
space:
mode:
authorBenjamin Coenen <[email protected]>2020-05-21 09:53:29 +0100
committerBenjamin Coenen <[email protected]>2020-05-21 09:53:29 +0100
commita7c8aa7c60c05db66ba4e89ae9e05c82e62507a5 (patch)
treee848f47bdf5d031c408df94222f595d2efcb2070 /editors/code/src/commands/runnables.ts
parentc6143742bd4e625d391ac3ea860be7578ab9f53f (diff)
parenta4e6963a2313971fe7bbec97d03bc67266ef68a9 (diff)
add support of feature flag for runnables #4464
Signed-off-by: Benjamin Coenen <[email protected]>
Diffstat (limited to 'editors/code/src/commands/runnables.ts')
-rw-r--r--editors/code/src/commands/runnables.ts17
1 files changed, 14 insertions, 3 deletions
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts
index b1d93fc34..0bd30fb07 100644
--- a/editors/code/src/commands/runnables.ts
+++ b/editors/code/src/commands/runnables.ts
@@ -7,7 +7,7 @@ import { startDebugSession, getDebugConfiguration } from '../debug';
7 7
8const quickPickButtons = [{ iconPath: new vscode.ThemeIcon("save"), tooltip: "Save as a launch.json configurtation." }]; 8const quickPickButtons = [{ iconPath: new vscode.ThemeIcon("save"), tooltip: "Save as a launch.json configurtation." }];
9 9
10async function selectRunnable(ctx: Ctx, prevRunnable?: RunnableQuickPick, showButtons: boolean = true): Promise<RunnableQuickPick | undefined> { 10async function selectRunnable(ctx: Ctx, prevRunnable?: RunnableQuickPick, debuggeeOnly = false, showButtons: boolean = true): Promise<RunnableQuickPick | undefined> {
11 const editor = ctx.activeRustEditor; 11 const editor = ctx.activeRustEditor;
12 const client = ctx.client; 12 const client = ctx.client;
13 if (!editor || !client) return; 13 if (!editor || !client) return;
@@ -33,9 +33,20 @@ async function selectRunnable(ctx: Ctx, prevRunnable?: RunnableQuickPick, showBu
33 ) { 33 ) {
34 continue; 34 continue;
35 } 35 }
36
37 if (debuggeeOnly && (r.label.startsWith('doctest') || r.label.startsWith('cargo'))) {
38 continue;
39 }
36 items.push(new RunnableQuickPick(r)); 40 items.push(new RunnableQuickPick(r));
37 } 41 }
38 42
43 if (items.length === 0) {
44 // it is the debug case, run always has at least 'cargo check ...'
45 // see crates\rust-analyzer\src\main_loop\handlers.rs, handle_runnables
46 vscode.window.showErrorMessage("There's no debug target!");
47 return;
48 }
49
39 return await new Promise((resolve) => { 50 return await new Promise((resolve) => {
40 const disposables: vscode.Disposable[] = []; 51 const disposables: vscode.Disposable[] = [];
41 const close = (result?: RunnableQuickPick) => { 52 const close = (result?: RunnableQuickPick) => {
@@ -107,7 +118,7 @@ export function debug(ctx: Ctx): Cmd {
107 let prevDebuggee: RunnableQuickPick | undefined; 118 let prevDebuggee: RunnableQuickPick | undefined;
108 119
109 return async () => { 120 return async () => {
110 const item = await selectRunnable(ctx, prevDebuggee); 121 const item = await selectRunnable(ctx, prevDebuggee, true);
111 if (!item) return; 122 if (!item) return;
112 123
113 item.detail = 'restart'; 124 item.detail = 'restart';
@@ -147,7 +158,7 @@ async function makeDebugConfig(ctx: Ctx, item: RunnableQuickPick): Promise<void>
147 158
148export function newDebugConfig(ctx: Ctx): Cmd { 159export function newDebugConfig(ctx: Ctx): Cmd {
149 return async () => { 160 return async () => {
150 const item = await selectRunnable(ctx, undefined, false); 161 const item = await selectRunnable(ctx, undefined, true, false);
151 if (!item) return; 162 if (!item) return;
152 163
153 await makeDebugConfig(ctx, item); 164 await makeDebugConfig(ctx, item);