diff options
Diffstat (limited to 'editors/code/src/commands.ts')
-rw-r--r-- | editors/code/src/commands.ts | 74 |
1 files changed, 60 insertions, 14 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index 86302db37..534d2a984 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts | |||
@@ -8,6 +8,7 @@ import { spawnSync } from 'child_process'; | |||
8 | import { RunnableQuickPick, selectRunnable, createTask } from './run'; | 8 | import { RunnableQuickPick, selectRunnable, createTask } from './run'; |
9 | import { AstInspector } from './ast_inspector'; | 9 | import { AstInspector } from './ast_inspector'; |
10 | import { isRustDocument, sleep, isRustEditor } from './util'; | 10 | import { isRustDocument, sleep, isRustEditor } from './util'; |
11 | import { startDebugSession, makeDebugConfig } from './debug'; | ||
11 | 12 | ||
12 | export * from './ast_inspector'; | 13 | export * from './ast_inspector'; |
13 | export * from './run'; | 14 | export * from './run'; |
@@ -197,20 +198,6 @@ export function toggleInlayHints(ctx: Ctx): Cmd { | |||
197 | }; | 198 | }; |
198 | } | 199 | } |
199 | 200 | ||
200 | export function run(ctx: Ctx): Cmd { | ||
201 | let prevRunnable: RunnableQuickPick | undefined; | ||
202 | |||
203 | return async () => { | ||
204 | const item = await selectRunnable(ctx, prevRunnable); | ||
205 | if (!item) return; | ||
206 | |||
207 | item.detail = 'rerun'; | ||
208 | prevRunnable = item; | ||
209 | const task = createTask(item.runnable); | ||
210 | return await vscode.tasks.executeTask(task); | ||
211 | }; | ||
212 | } | ||
213 | |||
214 | // Opens the virtual file that will show the syntax tree | 201 | // Opens the virtual file that will show the syntax tree |
215 | // | 202 | // |
216 | // The contents of the file come from the `TextDocumentContentProvider` | 203 | // The contents of the file come from the `TextDocumentContentProvider` |
@@ -368,3 +355,62 @@ export function applySnippetWorkspaceEditCommand(_ctx: Ctx): Cmd { | |||
368 | await applySnippetWorkspaceEdit(edit); | 355 | await applySnippetWorkspaceEdit(edit); |
369 | }; | 356 | }; |
370 | } | 357 | } |
358 | |||
359 | export function run(ctx: Ctx): Cmd { | ||
360 | let prevRunnable: RunnableQuickPick | undefined; | ||
361 | |||
362 | return async () => { | ||
363 | const item = await selectRunnable(ctx, prevRunnable); | ||
364 | if (!item) return; | ||
365 | |||
366 | item.detail = 'rerun'; | ||
367 | prevRunnable = item; | ||
368 | const task = createTask(item.runnable); | ||
369 | return await vscode.tasks.executeTask(task); | ||
370 | }; | ||
371 | } | ||
372 | |||
373 | export function runSingle(ctx: Ctx): Cmd { | ||
374 | return async (runnable: ra.Runnable) => { | ||
375 | const editor = ctx.activeRustEditor; | ||
376 | if (!editor) return; | ||
377 | |||
378 | const task = createTask(runnable); | ||
379 | task.group = vscode.TaskGroup.Build; | ||
380 | task.presentationOptions = { | ||
381 | reveal: vscode.TaskRevealKind.Always, | ||
382 | panel: vscode.TaskPanelKind.Dedicated, | ||
383 | clear: true, | ||
384 | }; | ||
385 | |||
386 | return vscode.tasks.executeTask(task); | ||
387 | }; | ||
388 | } | ||
389 | |||
390 | export function debug(ctx: Ctx): Cmd { | ||
391 | let prevDebuggee: RunnableQuickPick | undefined; | ||
392 | |||
393 | return async () => { | ||
394 | const item = await selectRunnable(ctx, prevDebuggee, true); | ||
395 | if (!item) return; | ||
396 | |||
397 | item.detail = 'restart'; | ||
398 | prevDebuggee = item; | ||
399 | return await startDebugSession(ctx, item.runnable); | ||
400 | }; | ||
401 | } | ||
402 | |||
403 | export function debugSingle(ctx: Ctx): Cmd { | ||
404 | return async (config: ra.Runnable) => { | ||
405 | await startDebugSession(ctx, config); | ||
406 | }; | ||
407 | } | ||
408 | |||
409 | export function newDebugConfig(ctx: Ctx): Cmd { | ||
410 | return async () => { | ||
411 | const item = await selectRunnable(ctx, undefined, true, false); | ||
412 | if (!item) return; | ||
413 | |||
414 | await makeDebugConfig(ctx, item.runnable); | ||
415 | }; | ||
416 | } | ||