aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands.ts
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-02-10 11:28:13 +0000
committerAleksey Kladov <[email protected]>2021-02-10 11:37:27 +0000
commit97166e2ad9307b3f4cca33d2c82149be9eb5a633 (patch)
tree8632550e4386b11b09deaacb38bf67929fe03f93 /editors/code/src/commands.ts
parent36465b34b3b7f991ebf85680924acdb809b0494e (diff)
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`.
Diffstat (limited to 'editors/code/src/commands.ts')
-rw-r--r--editors/code/src/commands.ts14
1 files changed, 13 insertions, 1 deletions
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';
5import { Ctx, Cmd } from './ctx'; 5import { Ctx, Cmd } from './ctx';
6import { applySnippetWorkspaceEdit, applySnippetTextEdits } from './snippets'; 6import { applySnippetWorkspaceEdit, applySnippetTextEdits } from './snippets';
7import { spawnSync } from 'child_process'; 7import { spawnSync } from 'child_process';
8import { RunnableQuickPick, selectRunnable, createTask } from './run'; 8import { RunnableQuickPick, selectRunnable, createTask, createArgs } from './run';
9import { AstInspector } from './ast_inspector'; 9import { AstInspector } from './ast_inspector';
10import { isRustDocument, sleep, isRustEditor } from './util'; 10import { isRustDocument, sleep, isRustEditor } from './util';
11import { startDebugSession, makeDebugConfig } from './debug'; 11import { startDebugSession, makeDebugConfig } from './debug';
@@ -572,6 +572,18 @@ export function runSingle(ctx: Ctx): Cmd {
572 }; 572 };
573} 573}
574 574
575export function copyRunCommandLine(ctx: Ctx) {
576 let prevRunnable: RunnableQuickPick | undefined;
577 return async () => {
578 const item = await selectRunnable(ctx, prevRunnable);
579 if (!item) return;
580 const args = createArgs(item.runnable);
581 const commandLine = ["cargo", ...args].join(" ");
582 await vscode.env.clipboard.writeText(commandLine);
583 await vscode.window.showInformationMessage("Cargo invocation copied to the clipboard.");
584 };
585}
586
575export function debug(ctx: Ctx): Cmd { 587export function debug(ctx: Ctx): Cmd {
576 let prevDebuggee: RunnableQuickPick | undefined; 588 let prevDebuggee: RunnableQuickPick | undefined;
577 589