Add **Copy Run Command Line** command for vscode

This is useful when you want to, e.g., run a specific test in a terminal
with `--release`.
This commit is contained in:
Aleksey Kladov 2021-02-10 14:28:13 +03:00
parent 36465b34b3
commit 97166e2ad9
4 changed files with 31 additions and 8 deletions

View file

@ -5,7 +5,7 @@ import * as ra from './lsp_ext';
import { Ctx, Cmd } from './ctx';
import { applySnippetWorkspaceEdit, applySnippetTextEdits } from './snippets';
import { spawnSync } from 'child_process';
import { RunnableQuickPick, selectRunnable, createTask } from './run';
import { RunnableQuickPick, selectRunnable, createTask, createArgs } from './run';
import { AstInspector } from './ast_inspector';
import { isRustDocument, sleep, isRustEditor } from './util';
import { startDebugSession, makeDebugConfig } from './debug';
@ -572,6 +572,18 @@ export function runSingle(ctx: Ctx): Cmd {
};
}
export function copyRunCommandLine(ctx: Ctx) {
let prevRunnable: RunnableQuickPick | undefined;
return async () => {
const item = await selectRunnable(ctx, prevRunnable);
if (!item) return;
const args = createArgs(item.runnable);
const commandLine = ["cargo", ...args].join(" ");
await vscode.env.clipboard.writeText(commandLine);
await vscode.window.showInformationMessage("Cargo invocation copied to the clipboard.");
};
}
export function debug(ctx: Ctx): Cmd {
let prevDebuggee: RunnableQuickPick | undefined;