aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands/runnables.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/commands/runnables.ts')
-rw-r--r--editors/code/src/commands/runnables.ts33
1 files changed, 25 insertions, 8 deletions
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts
index 40f590dce..c234bfaec 100644
--- a/editors/code/src/commands/runnables.ts
+++ b/editors/code/src/commands/runnables.ts
@@ -41,39 +41,56 @@ function createTask(spec: Runnable): vscode.Task {
41 label: 'cargo', 41 label: 'cargo',
42 command: spec.bin, 42 command: spec.bin,
43 args: spec.args, 43 args: spec.args,
44 env: spec.env, 44 env: spec.env
45 }; 45 };
46 46
47 const execCmd = `${definition.command} ${definition.args.join(' ')}`; 47 const execCmd = `${definition.command} ${definition.args.join(' ')}`;
48 const execOption: vscode.ShellExecutionOptions = { 48 const execOption: vscode.ShellExecutionOptions = {
49 cwd: '.', 49 cwd: '.',
50 env: definition.env, 50 env: definition.env
51 }; 51 };
52 const exec = new vscode.ShellExecution(`clear; ${execCmd}`, execOption); 52 const exec = new vscode.ShellExecution(`clear; ${execCmd}`, execOption);
53 53
54 const f = vscode.workspace.workspaceFolders![0]; 54 const f = vscode.workspace.workspaceFolders![0];
55 const t = new vscode.Task(definition, f, definition.label, TASK_SOURCE, exec, ['$rustc']); 55 const t = new vscode.Task(
56 definition,
57 f,
58 definition.label,
59 TASK_SOURCE,
60 exec,
61 ['$rustc']
62 );
56 return t; 63 return t;
57} 64}
58 65
59let prevRunnable: RunnableQuickPick | undefined; 66let prevRunnable: RunnableQuickPick | undefined;
60export async function handle() { 67export async function handle() {
61 const editor = vscode.window.activeTextEditor; 68 const editor = vscode.window.activeTextEditor;
62 if (editor == null || editor.document.languageId !== 'rust') { return; } 69 if (editor == null || editor.document.languageId !== 'rust') {
70 return;
71 }
63 const textDocument: lc.TextDocumentIdentifier = { 72 const textDocument: lc.TextDocumentIdentifier = {
64 uri: editor.document.uri.toString(), 73 uri: editor.document.uri.toString()
65 }; 74 };
66 const params: RunnablesParams = { 75 const params: RunnablesParams = {
67 textDocument, 76 textDocument,
68 position: Server.client.code2ProtocolConverter.asPosition(editor.selection.active), 77 position: Server.client.code2ProtocolConverter.asPosition(
78 editor.selection.active
79 )
69 }; 80 };
70 const runnables = await Server.client.sendRequest<Runnable[]>('m/runnables', params); 81 const runnables = await Server.client.sendRequest<Runnable[]>(
82 'm/runnables',
83 params
84 );
71 const items: RunnableQuickPick[] = []; 85 const items: RunnableQuickPick[] = [];
72 if (prevRunnable) { 86 if (prevRunnable) {
73 items.push(prevRunnable); 87 items.push(prevRunnable);
74 } 88 }
75 for (const r of runnables) { 89 for (const r of runnables) {
76 if (prevRunnable && JSON.stringify(prevRunnable.runnable) === JSON.stringify(r)) { 90 if (
91 prevRunnable &&
92 JSON.stringify(prevRunnable.runnable) === JSON.stringify(r)
93 ) {
77 continue; 94 continue;
78 } 95 }
79 items.push(new RunnableQuickPick(r)); 96 items.push(new RunnableQuickPick(r));