mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Move run commands to commands.ts
This commit is contained in:
parent
131ccd9540
commit
0ced18eee0
3 changed files with 138 additions and 137 deletions
|
@ -8,6 +8,7 @@ import { spawnSync } from 'child_process';
|
|||
import { RunnableQuickPick, selectRunnable, createTask } from './run';
|
||||
import { AstInspector } from './ast_inspector';
|
||||
import { isRustDocument, sleep, isRustEditor } from './util';
|
||||
import { startDebugSession, makeDebugConfig } from './debug';
|
||||
|
||||
export * from './ast_inspector';
|
||||
export * from './run';
|
||||
|
@ -197,20 +198,6 @@ export function toggleInlayHints(ctx: Ctx): Cmd {
|
|||
};
|
||||
}
|
||||
|
||||
export function run(ctx: Ctx): Cmd {
|
||||
let prevRunnable: RunnableQuickPick | undefined;
|
||||
|
||||
return async () => {
|
||||
const item = await selectRunnable(ctx, prevRunnable);
|
||||
if (!item) return;
|
||||
|
||||
item.detail = 'rerun';
|
||||
prevRunnable = item;
|
||||
const task = createTask(item.runnable);
|
||||
return await vscode.tasks.executeTask(task);
|
||||
};
|
||||
}
|
||||
|
||||
// Opens the virtual file that will show the syntax tree
|
||||
//
|
||||
// The contents of the file come from the `TextDocumentContentProvider`
|
||||
|
@ -368,3 +355,62 @@ export function applySnippetWorkspaceEditCommand(_ctx: Ctx): Cmd {
|
|||
await applySnippetWorkspaceEdit(edit);
|
||||
};
|
||||
}
|
||||
|
||||
export function run(ctx: Ctx): Cmd {
|
||||
let prevRunnable: RunnableQuickPick | undefined;
|
||||
|
||||
return async () => {
|
||||
const item = await selectRunnable(ctx, prevRunnable);
|
||||
if (!item) return;
|
||||
|
||||
item.detail = 'rerun';
|
||||
prevRunnable = item;
|
||||
const task = createTask(item.runnable);
|
||||
return await vscode.tasks.executeTask(task);
|
||||
};
|
||||
}
|
||||
|
||||
export function runSingle(ctx: Ctx): Cmd {
|
||||
return async (runnable: ra.Runnable) => {
|
||||
const editor = ctx.activeRustEditor;
|
||||
if (!editor) return;
|
||||
|
||||
const task = createTask(runnable);
|
||||
task.group = vscode.TaskGroup.Build;
|
||||
task.presentationOptions = {
|
||||
reveal: vscode.TaskRevealKind.Always,
|
||||
panel: vscode.TaskPanelKind.Dedicated,
|
||||
clear: true,
|
||||
};
|
||||
|
||||
return vscode.tasks.executeTask(task);
|
||||
};
|
||||
}
|
||||
|
||||
export function debug(ctx: Ctx): Cmd {
|
||||
let prevDebuggee: RunnableQuickPick | undefined;
|
||||
|
||||
return async () => {
|
||||
const item = await selectRunnable(ctx, prevDebuggee, true);
|
||||
if (!item) return;
|
||||
|
||||
item.detail = 'restart';
|
||||
prevDebuggee = item;
|
||||
return await startDebugSession(ctx, item.runnable);
|
||||
};
|
||||
}
|
||||
|
||||
export function debugSingle(ctx: Ctx): Cmd {
|
||||
return async (config: ra.Runnable) => {
|
||||
await startDebugSession(ctx, config);
|
||||
};
|
||||
}
|
||||
|
||||
export function newDebugConfig(ctx: Ctx): Cmd {
|
||||
return async () => {
|
||||
const item = await selectRunnable(ctx, undefined, true, false);
|
||||
if (!item) return;
|
||||
|
||||
await makeDebugConfig(ctx, item.runnable);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue