diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-02-10 11:38:56 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-10 11:38:56 +0000 |
commit | 82a1b91f205ac9c3d397b2bea033639f5df9e6b6 (patch) | |
tree | 4683820d7a28c6bc991992a8c1978c3bf87b1b61 /editors/code/src/commands.ts | |
parent | 5e39d7a68032ba40d3ed76d41d0f01ad628f5c95 (diff) | |
parent | 97166e2ad9307b3f4cca33d2c82149be9eb5a633 (diff) |
Merge #7625
7625: Add **Copy Run Command Line** command for vscode r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'editors/code/src/commands.ts')
-rw-r--r-- | editors/code/src/commands.ts | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index 3729a71de..283b9a160 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts | |||
@@ -5,7 +5,7 @@ import * as ra from './lsp_ext'; | |||
5 | import { Ctx, Cmd } from './ctx'; | 5 | import { Ctx, Cmd } from './ctx'; |
6 | import { applySnippetWorkspaceEdit, applySnippetTextEdits } from './snippets'; | 6 | import { applySnippetWorkspaceEdit, applySnippetTextEdits } from './snippets'; |
7 | import { spawnSync } from 'child_process'; | 7 | import { spawnSync } from 'child_process'; |
8 | import { RunnableQuickPick, selectRunnable, createTask } from './run'; | 8 | import { RunnableQuickPick, selectRunnable, createTask, createArgs } 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 | import { startDebugSession, makeDebugConfig } from './debug'; |
@@ -572,6 +572,18 @@ export function runSingle(ctx: Ctx): Cmd { | |||
572 | }; | 572 | }; |
573 | } | 573 | } |
574 | 574 | ||
575 | export 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 | |||
575 | export function debug(ctx: Ctx): Cmd { | 587 | export function debug(ctx: Ctx): Cmd { |
576 | let prevDebuggee: RunnableQuickPick | undefined; | 588 | let prevDebuggee: RunnableQuickPick | undefined; |
577 | 589 | ||