diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-10-09 07:16:36 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-10-09 07:16:36 +0100 |
commit | c9798c0e6da53c132021f03ac7a50ccd8714b371 (patch) | |
tree | 0d6d49b2eb40ad161a72adbfbf9874b64540bf74 /editors/code/src/commands/runnables.ts | |
parent | f4ad36e972989c3feed8671d6d6fca0aed37cd8f (diff) | |
parent | e26071d96e1ff56289213dbe78415f836de8a70e (diff) |
Merge #104
104: Add vscode extension to CI r=aochagavia a=DJMcNab
Note that this testing is only done on travis - we are only running formatting and linting, so feature parity on appveyor is not required.
CC @aochagavia.
Fixes? #100
Co-authored-by: Daniel McNab <[email protected]>
Diffstat (limited to 'editors/code/src/commands/runnables.ts')
-rw-r--r-- | editors/code/src/commands/runnables.ts | 33 |
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 | ||
59 | let prevRunnable: RunnableQuickPick | undefined; | 66 | let prevRunnable: RunnableQuickPick | undefined; |
60 | export async function handle() { | 67 | export 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)); |