@@ -7,7 +7,7 @@ import { startDebugSession, getDebugConfiguration } from '../debug';
77
88const quickPickButtons = [ { iconPath : new vscode . ThemeIcon ( "save" ) , tooltip : "Save as a launch.json configurtation." } ] ;
99
10- async function selectRunnable ( ctx : Ctx , prevRunnable ?: RunnableQuickPick , showButtons : boolean = true ) : Promise < RunnableQuickPick | undefined > {
10+ async function selectRunnable ( ctx : Ctx , prevRunnable ?: RunnableQuickPick , debuggeeOnly = false , showButtons : boolean = true ) : Promise < RunnableQuickPick | undefined > {
1111 const editor = ctx . activeRustEditor ;
1212 const client = ctx . client ;
1313 if ( ! editor || ! client ) return ;
@@ -33,9 +33,20 @@ async function selectRunnable(ctx: Ctx, prevRunnable?: RunnableQuickPick, showBu
3333 ) {
3434 continue ;
3535 }
36+
37+ if ( debuggeeOnly && ( r . label . startsWith ( 'doctest' ) || r . label . startsWith ( 'cargo' ) ) ) {
38+ continue ;
39+ }
3640 items . push ( new RunnableQuickPick ( r ) ) ;
3741 }
3842
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+
3950 return await new Promise ( ( resolve ) => {
4051 const disposables : vscode . Disposable [ ] = [ ] ;
4152 const close = ( result ?: RunnableQuickPick ) => {
@@ -107,7 +118,7 @@ export function debug(ctx: Ctx): Cmd {
107118 let prevDebuggee : RunnableQuickPick | undefined ;
108119
109120 return async ( ) => {
110- const item = await selectRunnable ( ctx , prevDebuggee ) ;
121+ const item = await selectRunnable ( ctx , prevDebuggee , true ) ;
111122 if ( ! item ) return ;
112123
113124 item . detail = 'restart' ;
@@ -147,7 +158,7 @@ async function makeDebugConfig(ctx: Ctx, item: RunnableQuickPick): Promise<void>
147158
148159export function newDebugConfig ( ctx : Ctx ) : Cmd {
149160 return async ( ) => {
150- const item = await selectRunnable ( ctx , undefined , false ) ;
161+ const item = await selectRunnable ( ctx , undefined , true , false ) ;
151162 if ( ! item ) return ;
152163
153164 await makeDebugConfig ( ctx , item ) ;
0 commit comments