Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Commit 42be477

Browse files
authored
Merge pull request #361 from matklad/tasks-on-1.25
Fix tasks on VSCode 1.25
2 parents 88f4c30 + a26e89f commit 42be477

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

package.json

+22
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,28 @@
105105
}
106106
]
107107
},
108+
"taskDefinitions": [
109+
{
110+
"type": "cargo",
111+
"required": [
112+
"command"
113+
],
114+
"properties": {
115+
"label": {
116+
"type": "string"
117+
},
118+
"command": {
119+
"type": "string"
120+
},
121+
"args": {
122+
"type": "array"
123+
},
124+
"env": {
125+
"type": "object"
126+
}
127+
}
128+
}
129+
],
108130
"problemMatchers": [
109131
{
110132
"name": "rustc",

src/tasks.ts

+11-12
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
import { Disposable, ShellExecution, ShellExecutionOptions, Task, TaskDefinition, TaskGroup, TaskPanelKind, TaskPresentationOptions, TaskProvider, TaskRevealKind, WorkspaceFolder, workspace, tasks } from 'vscode';
11+
import { Disposable, ShellExecution, ShellExecutionOptions, Task, TaskDefinition, TaskGroup, TaskPanelKind, TaskPresentationOptions, TaskProvider, TaskRevealKind, WorkspaceFolder, workspace, tasks, TaskExecution } from 'vscode';
1212

1313
export function activateTaskProvider(target: WorkspaceFolder): Disposable {
1414
const provider: TaskProvider = {
@@ -28,8 +28,7 @@ export function activateTaskProvider(target: WorkspaceFolder): Disposable {
2828
}
2929

3030
interface CargoTaskDefinition extends TaskDefinition {
31-
// FIXME: By the document, we should add the `taskDefinitions` section to our package.json and use the value of it.
32-
type: 'shell';
31+
type: 'cargo';
3332
label: string;
3433
command: string;
3534
args: Array<string>;
@@ -89,7 +88,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
8988
{
9089
definition: {
9190
label: 'cargo build',
92-
type: 'shell',
91+
type: 'cargo',
9392
command: 'cargo',
9493
args: [
9594
'build'
@@ -102,7 +101,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
102101
{
103102
definition: {
104103
label: 'cargo check',
105-
type: 'shell',
104+
type: 'cargo',
106105
command: 'cargo',
107106
args: [
108107
'check'
@@ -115,7 +114,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
115114
{
116115
definition: {
117116
label: 'cargo run',
118-
type: 'shell',
117+
type: 'cargo',
119118
command: 'cargo',
120119
args: [
121120
'run'
@@ -127,7 +126,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
127126
{
128127
definition: {
129128
label: 'cargo test',
130-
type: 'shell',
129+
type: 'cargo',
131130
command: 'cargo',
132131
args: [
133132
'test'
@@ -140,7 +139,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
140139
{
141140
definition: {
142141
label: 'cargo bench',
143-
type: 'shell',
142+
type: 'cargo',
144143
command: 'cargo',
145144
args: [
146145
'+nightly',
@@ -154,7 +153,7 @@ function createTaskConfigItem(): Array<TaskConfigItem> {
154153
{
155154
definition: {
156155
label: 'cargo clean',
157-
type: 'shell',
156+
type: 'cargo',
158157
command: 'cargo',
159158
args: [
160159
'clean'
@@ -174,11 +173,11 @@ export interface Cmd {
174173
env: { [key: string]: string };
175174
}
176175

177-
export function runCommand(folder: WorkspaceFolder, cmd: Cmd) {
176+
export function runCommand(folder: WorkspaceFolder, cmd: Cmd): Thenable<TaskExecution> {
178177
const config: TaskConfigItem = {
179178
definition: {
180179
label: 'run Cargo command',
181-
type: 'shell',
180+
type: 'cargo',
182181
command: cmd.binary,
183182
args: cmd.args,
184183
env: cmd.env,
@@ -191,5 +190,5 @@ export function runCommand(folder: WorkspaceFolder, cmd: Cmd) {
191190
},
192191
};
193192
const task = createTask(config, folder);
194-
tasks.executeTask(task);
193+
return tasks.executeTask(task);
195194
}

0 commit comments

Comments
 (0)