From 97166e2ad9307b3f4cca33d2c82149be9eb5a633 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 10 Feb 2021 14:28:13 +0300 Subject: 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`. --- editors/code/src/commands.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'editors/code/src/commands.ts') diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index cbda619ea..e3a23c0d2 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts @@ -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; -- cgit v1.2.3