about summary refs log tree commit diff
path: root/editors/code
diff options
context:
space:
mode:
authorvsrs <vit@conrlab.com>2020-05-17 20:29:59 +0300
committervsrs <vit@conrlab.com>2020-05-17 20:29:59 +0300
commitdec2f3fa657a2700f9db1962891e7be71c299543 (patch)
treeef7ae5512c7c78f44a56ae2395ca5d32edc5b3a2 /editors/code
parentdc217bdf90d555eaa1780041fc3a14e64173994d (diff)
downloadrust-dec2f3fa657a2700f9db1962891e7be71c299543.tar.gz
rust-dec2f3fa657a2700f9db1962891e7be71c299543.zip
Runnable QuickPick with debuggees only
Diffstat (limited to 'editors/code')
-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 b1d93fc34eb..a408021e788 100644
--- a/editors/code/src/commands/runnables.ts
+++ b/editors/code/src/commands/runnables.ts
@@ -7,7 +7,7 @@ import { startDebugSession, getDebugConfiguration } from '../debug';
 
 const quickPickButtons = [{ iconPath: new vscode.ThemeIcon("save"), tooltip: "Save as a launch.json configurtation." }];
 
-async function selectRunnable(ctx: Ctx, prevRunnable?: RunnableQuickPick, showButtons: boolean = true): Promise<RunnableQuickPick | undefined> {
+async function selectRunnable(ctx: Ctx, prevRunnable?: RunnableQuickPick, debuggeeOnly = false, showButtons: boolean = true): Promise<RunnableQuickPick | undefined> {
     const editor = ctx.activeRustEditor;
     const client = ctx.client;
     if (!editor || !client) return;
@@ -33,9 +33,20 @@ async function selectRunnable(ctx: Ctx, prevRunnable?: RunnableQuickPick, showBu
         ) {
             continue;
         }
+
+        if (debuggeeOnly && (r.label.startsWith('doctest') || r.label.startsWith('cargo'))) {
+            continue;
+        }
         items.push(new RunnableQuickPick(r));
     }
 
+    if( items.length === 0 ) {
+        // it is the debug case, run always has at least 'cargo check ...'
+        // see crates\rust-analyzer\src\main_loop\handlers.rs, handle_runnables
+        vscode.window.showErrorMessage("There's no debug target!");
+        return;
+    }
+
     return await new Promise((resolve) => {
         const disposables: vscode.Disposable[] = [];
         const close = (result?: RunnableQuickPick) => {
@@ -107,7 +118,7 @@ export function debug(ctx: Ctx): Cmd {
     let prevDebuggee: RunnableQuickPick | undefined;
 
     return async () => {
-        const item = await selectRunnable(ctx, prevDebuggee);
+        const item = await selectRunnable(ctx, prevDebuggee, true);
         if (!item) return;
 
         item.detail = 'restart';
@@ -147,7 +158,7 @@ async function makeDebugConfig(ctx: Ctx, item: RunnableQuickPick): Promise<void>
 
 export function newDebugConfig(ctx: Ctx): Cmd {
     return async () => {
-        const item = await selectRunnable(ctx, undefined, false);
+        const item = await selectRunnable(ctx, undefined, true, false);
         if (!item) return;
 
         await makeDebugConfig(ctx, item);