Skip to content

Commit acc5797

Browse files
committed
feat: support multi-root workspaces
1 parent 00afaca commit acc5797

File tree

10 files changed

+310
-116
lines changed

10 files changed

+310
-116
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ This extension integrates your Taskfile into Visual Studio Code.
77
- View tasks in the activity bar
88
- Run tasks from the activity bar and command palette
99
- Go to definition
10+
- Multi-root workspace support
1011

1112
## Roadmap
1213

1314
- Run last task command
15+
- Loading icon when a task is running in tree view
1416
- Stream output to output channel instead of waiting for command to finish
1517
- Switch between nested/flat task view
1618
- Refresh up-to-date status when a task's sources change
1719
- Status polling to update up-to-date status
1820
- Support global tasks
19-
- Support workspaces
2021
- Install Task via command palette
2122
- Prompt if a Taskfile is detected and Task is not installed
2223
- If no Taskfile is detected, add a button to initialise one

package.json

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,28 @@
117117
},
118118
"colors": [
119119
{
120-
"id": "vscodetask.namespace",
121-
"description": "Color for up-to-date tasks in the activity bar.",
120+
"id": "vscodetask.workspaceIcon",
121+
"description": "Color for workspace icons in the activity bar.",
122122
"defaults": {
123-
"dark": "#5FBBB0",
124-
"light": "#5FBBB0",
125-
"highContrast": "#5FBBB0",
126-
"highContrastLight": "#5FBBB0"
123+
"dark": "#2e85e7",
124+
"light": "#2e85e7",
125+
"highContrast": "#2e85e7",
126+
"highContrastLight": "#2e85e7"
127127
}
128128
},
129129
{
130-
"id": "vscodetask.upToDate",
131-
"description": "Color for up-to-date tasks in the activity bar.",
130+
"id": "vscodetask.namespaceIcon",
131+
"description": "Color for namespace icons in the activity bar.",
132+
"defaults": {
133+
"dark": "#a677ff",
134+
"light": "#a677ff",
135+
"highContrast": "#a677ff",
136+
"highContrastLight": "#a677ff"
137+
}
138+
},
139+
{
140+
"id": "vscodetask.upToDateIcon",
141+
"description": "Color for up-to-date task icons in the activity bar.",
132142
"defaults": {
133143
"dark": "#00AA00",
134144
"light": "#00AA00",
@@ -137,13 +147,13 @@
137147
}
138148
},
139149
{
140-
"id": "vscodetask.outOfDate",
141-
"description": "Color for out-of-date tasks in the activity bar.",
150+
"id": "vscodetask.outOfDateIcon",
151+
"description": "Color for out-of-date task icons in the activity bar.",
142152
"defaults": {
143-
"dark": "#AAAAAA",
144-
"light": "#AAAAAA",
145-
"highContrast": "#AAAAAA",
146-
"highContrastLight": "#AAAAAA"
153+
"dark": "#ff9b05",
154+
"light": "#ff9b05",
155+
"highContrast": "#ff9b05",
156+
"highContrastLight": "#ff9b05"
147157
}
148158
}
149159
],

src/elements/activityBar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class ActivityBar {
1616
});
1717
}
1818

19-
public refresh(taskfile?: models.Taskfile) {
20-
this._provider.refresh(taskfile);
19+
public refresh(taskfiles: models.Taskfile[]) {
20+
this._provider.refresh(taskfiles);
2121
}
2222
}

src/elements/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export * from './activityBar';
2+
export * from './quickPickItem';
3+
export * from './treeItem';

src/elements/quickPickItem.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import * as vscode from 'vscode';
2+
import * as models from '../models';
3+
4+
export class QuickPickTaskItem implements vscode.QuickPickItem {
5+
constructor(taskfile: models.Taskfile, task: models.Task) {
6+
this.taskfile = taskfile;
7+
this.task = task;
8+
this.label = task.name;
9+
this.description = task.desc;
10+
this.kind = vscode.QuickPickItemKind.Default;
11+
}
12+
taskfile: models.Taskfile;
13+
task: models.Task;
14+
label: string;
15+
description: string;
16+
kind: vscode.QuickPickItemKind;
17+
}
18+
19+
export class QuickPickTaskSeparator implements vscode.QuickPickItem {
20+
constructor(taskfile: models.Taskfile) {
21+
this.label = taskfile.location;
22+
this.kind = vscode.QuickPickItemKind.Separator;
23+
}
24+
label: string;
25+
kind: vscode.QuickPickItemKind;
26+
}

src/elements/treeItem.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import * as vscode from 'vscode';
2+
import * as models from '../models';
3+
4+
export type TreeItem = WorkspaceTreeItem | NamespaceTreeItem | TaskTreeItem;
5+
6+
export class WorkspaceTreeItem extends vscode.TreeItem {
7+
constructor(
8+
readonly label: string,
9+
readonly workspace: string,
10+
readonly tasks: models.Task[],
11+
readonly collapsibleState: vscode.TreeItemCollapsibleState,
12+
readonly command?: vscode.Command
13+
) {
14+
super(label, collapsibleState);
15+
this.description = this.workspace;
16+
this.iconPath = new vscode.ThemeIcon('folder', new vscode.ThemeColor('vscodetask.workspaceIcon'));
17+
this.contextValue = `workspaceTreeItem`;
18+
}
19+
}
20+
21+
export class NamespaceTreeItem extends vscode.TreeItem {
22+
constructor(
23+
readonly label: string,
24+
readonly workspace: string,
25+
readonly namespace: string,
26+
readonly tasks: models.Task[],
27+
readonly collapsibleState: vscode.TreeItemCollapsibleState,
28+
readonly command?: vscode.Command
29+
) {
30+
super(label, collapsibleState);
31+
this.iconPath = new vscode.ThemeIcon('symbol-namespace', new vscode.ThemeColor('vscodetask.namespaceIcon'));
32+
this.contextValue = `namespaceTreeItem`;
33+
}
34+
}
35+
36+
export class TaskTreeItem extends vscode.TreeItem {
37+
constructor(
38+
readonly label: string,
39+
readonly workspace: string,
40+
readonly task: models.Task,
41+
readonly collapsibleState: vscode.TreeItemCollapsibleState,
42+
readonly command?: vscode.Command
43+
) {
44+
super(label, collapsibleState);
45+
this.description = this.task?.desc;
46+
if (this.task.up_to_date) {
47+
this.iconPath = new vscode.ThemeIcon('debug-breakpoint-log-unverified', new vscode.ThemeColor('vscodetask.upToDateIcon'));
48+
} else {
49+
this.iconPath = new vscode.ThemeIcon('debug-breakpoint-data-unverified', new vscode.ThemeColor('vscodetask.outOfDateIcon'));
50+
}
51+
this.contextValue = `taskTreeItem`;
52+
}
53+
}

src/models/taskfile.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
export interface Taskfile {
22
tasks: Task[];
3+
location: string; // The location of the actual Taskfile
4+
// The vscode workspace directory where the command was executed to find this taskfile
5+
// This is where tasks in this taskfile will be executed from.
6+
workspace: string;
37
}
48

59
export interface Task {

0 commit comments

Comments
 (0)