Skip to content

Commit d57cb29

Browse files
committed
feat: disable status checking by default
- adds a new tree.status setting to reenable - change the default task icon color to task's primary color
1 parent 5a417cf commit d57cb29

File tree

7 files changed

+39
-7
lines changed

7 files changed

+39
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@
4545
| `checkForUpdates` | `boolean` | | `true` | Check if there is a newer version of Task on startup. |
4646
| `doubleClickTimeout` | `number` | | `500` | Time in milliseconds to consider a double-click. A value of 0 will disable double-clicking. |
4747
| `tree.nesting` | `boolean` | | `true` | Whether to nest tasks by their namespace in the tree view. |
48+
| `tree.status` | `boolean` | | `false` | Whether to show the status of tasks in the tree view (may be slow on large Taskfiles). |
4849
| `tree.sort` | `sort` | `default`, `alphanumeric`, `none` | `"default"` | The order in which to display tasks in the tree view. |

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,16 @@
263263
"highContrast": "#ff9b05",
264264
"highContrastLight": "#ff9b05"
265265
}
266+
},
267+
{
268+
"id": "vscodetask.primaryColor",
269+
"description": "Color for primary elements.",
270+
"defaults": {
271+
"dark": "#43aba2",
272+
"light": "#43aba2",
273+
"highContrast": "#43aba2",
274+
"highContrastLight": "#43aba2"
275+
}
266276
}
267277
],
268278
"configuration": {
@@ -314,6 +324,11 @@
314324
"default": true,
315325
"description": "Whether to nest tasks by their namespace in the tree view."
316326
},
327+
"status": {
328+
"type": "boolean",
329+
"default": false,
330+
"description": "Whether to show the status of tasks in the tree view (may be slow on large Taskfiles)."
331+
},
317332
"sort": {
318333
"type": "string",
319334
"enum": [

src/elements/treeItem.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ export class TaskTreeItem extends vscode.TreeItem {
4242
) {
4343
super(label, collapsibleState);
4444
this.description = this.task?.desc;
45-
if (this.task.up_to_date) {
46-
this.iconPath = new vscode.ThemeIcon('debug-breakpoint-log-unverified', new vscode.ThemeColor('vscodetask.upToDateIcon'));
47-
} else {
48-
this.iconPath = new vscode.ThemeIcon('debug-breakpoint-data-unverified', new vscode.ThemeColor('vscodetask.outOfDateIcon'));
45+
switch (this.task.up_to_date) {
46+
case true:
47+
this.iconPath = new vscode.ThemeIcon('debug-breakpoint-data-unverified', new vscode.ThemeColor('vscodetask.upToDateIcon'));
48+
break;
49+
case false:
50+
this.iconPath = new vscode.ThemeIcon('debug-breakpoint-data-unverified', new vscode.ThemeColor('vscodetask.outOfDateIcon'));
51+
break;
52+
default:
53+
this.iconPath = new vscode.ThemeIcon('debug-breakpoint-data-unverified', new vscode.ThemeColor('vscodetask.primaryColor'));
4954
}
5055
this.contextValue = `taskTreeItem`;
5156
}

src/models/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface Task {
1212
desc: string;
1313
summary: string;
1414
// eslint-disable-next-line @typescript-eslint/naming-convention
15-
up_to_date: boolean;
15+
up_to_date: boolean | undefined;
1616
location: Location;
1717
}
1818

src/services/taskfile.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class TaskfileService {
177177
}
178178
}
179179

180-
public async read(dir: string, nesting: boolean): Promise<Namespace | undefined> {
180+
public async read(dir: string, nesting: boolean, status: boolean): Promise<Namespace | undefined> {
181181
log.info(`Searching for taskfile in: "${dir}"`);
182182
return await new Promise((resolve, reject) => {
183183
let flags = [
@@ -191,6 +191,9 @@ class TaskfileService {
191191
if (nesting) {
192192
flags.push(`--nested`);
193193
}
194+
if (!status) {
195+
flags.push(`--no-status`);
196+
}
194197
let command = this.command(`${flags.join(' ')}`);
195198
cp.exec(command, { cwd: dir }, (err: cp.ExecException | null, stdout: string, stderr: string) => {
196199
if (err) {

src/task.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ export class TaskExtension {
1313
private _watcher: vscode.FileSystemWatcher;
1414
private _changeTimeout: NodeJS.Timeout | null = null;
1515
private _nesting: boolean;
16+
private _status: boolean;
1617

1718
constructor() {
1819
this._activityBar = new ActivityBar();
1920
this._watcher = vscode.workspace.createFileSystemWatcher("**/*.{yml,yaml}");
2021
this._nesting = settings.tree.nesting;
22+
this._status = settings.tree.status;
2123
}
2224

2325
public async update(checkForUpdates?: boolean): Promise<void> {
@@ -36,7 +38,7 @@ export class TaskExtension {
3638
// Read taskfiles
3739
let p: Promise<Namespace | undefined>[] = [];
3840
vscode.workspace.workspaceFolders?.forEach((folder) => {
39-
p.push(taskfileSvc.read(folder.uri.fsPath, this._nesting));
41+
p.push(taskfileSvc.read(folder.uri.fsPath, this._nesting, this._status));
4042
});
4143

4244
return Promise.allSettled(p);
@@ -288,6 +290,10 @@ export class TaskExtension {
288290
log.info("Detected changes to configuration");
289291
if (event.affectsConfiguration("task")) {
290292
settings.update();
293+
this._nesting = settings.tree.nesting;
294+
this._status = settings.tree.status;
295+
this.refresh(false);
296+
vscode.commands.executeCommand('setContext', 'vscode-task:treeNesting', this._nesting);
291297
}
292298
}
293299
}

src/utils/settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export enum UpdateOn {
5050
class TreeSettings {
5151
private static _instance: TreeSettings;
5252
public nesting!: boolean;
53+
public status!: boolean;
5354
public sort!: TreeSort;
5455

5556
constructor() {
@@ -69,6 +70,7 @@ class TreeSettings {
6970

7071
// Set the properties
7172
this.nesting = config.get("tree.nesting") ?? true;
73+
this.status = config.get("tree.status") ?? false;
7274
this.sort = config.get("tree.sort") ?? TreeSort.default;
7375
}
7476
}

0 commit comments

Comments
 (0)