Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"tasks": [
{
"type": "npm",
"script": "bundle",
"script": "compile",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@
| `checkForUpdates` | `boolean` | | `true` | Check if there is a newer version of Task on startup. |
| `doubleClickTimeout` | `number` | | `0` | Time in milliseconds to consider a double-click. 0 disables double-click to run. 500 is a good starting point if you want to enable it. |
| `tree.nesting` | `boolean` | | `true` | Whether to nest tasks by their namespace in the tree view. |
| `tree.status` | `boolean` | | `false` | Whether to show the status of tasks in the tree view (may be slow on large Taskfiles). |
| `tree.sort` | `sort` | `default`, `alphanumeric`, `none` | `"default"` | The order in which to display tasks in the tree view. |
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@
"highContrast": "#ff9b05",
"highContrastLight": "#ff9b05"
}
},
{
"id": "vscodetask.primaryColor",
"description": "Color for primary elements.",
"defaults": {
"dark": "#43aba2",
"light": "#43aba2",
"highContrast": "#43aba2",
"highContrastLight": "#43aba2"
}
}
],
"configuration": {
Expand Down Expand Up @@ -314,6 +324,11 @@
"default": true,
"description": "Whether to nest tasks by their namespace in the tree view."
},
"status": {
"type": "boolean",
"default": false,
"description": "Whether to show the status of tasks in the tree view (may be slow on large Taskfiles)."
},
"sort": {
"type": "string",
"enum": [
Expand Down
11 changes: 3 additions & 8 deletions src/elements/activityBar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from 'vscode';
import { TaskTreeDataProvider } from '../providers/taskTreeDataProvider.js';
import { Taskfile } from '../models/taskfile.js';
import { Namespace } from '../models/models.js';

export class ActivityBar {
private _provider: TaskTreeDataProvider;
Expand All @@ -16,12 +16,7 @@ export class ActivityBar {
});
}

public setTreeNesting(enabled: boolean) {
this._provider.setTreeNesting(enabled);
this._provider.refresh();
}

public refresh(taskfiles?: Taskfile[]) {
this._provider.refresh(taskfiles);
public refresh(taskfiles?: Namespace[], nesting?: boolean): void {
this._provider.refresh(taskfiles, nesting);
}
}
12 changes: 6 additions & 6 deletions src/elements/quickPickItem.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import * as vscode from 'vscode';
import { Taskfile, Task } from '../models/taskfile.js';
import { Namespace, Task } from '../models/models.js';

export class QuickPickTaskItem implements vscode.QuickPickItem {
constructor(taskfile: Taskfile, task: Task) {
this.taskfile = taskfile;
constructor(namespace: Namespace, task: Task) {
this.namespace = namespace;
this.task = task;
this.label = task.name;
this.description = task.desc;
this.kind = vscode.QuickPickItemKind.Default;
}
taskfile: Taskfile;
namespace: Namespace;
task: Task;
label: string;
description: string;
kind: vscode.QuickPickItemKind;
}

export class QuickPickTaskSeparator implements vscode.QuickPickItem {
constructor(taskfile: Taskfile) {
this.label = taskfile.location;
constructor(namespace: Namespace) {
this.label = namespace.location;
this.kind = vscode.QuickPickItemKind.Separator;
}
label: string;
Expand Down
42 changes: 32 additions & 10 deletions src/elements/treeItem.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@
import * as vscode from 'vscode';
import { Task } from '../models/taskfile.js';
import { Namespace, Task } from '../models/models.js';

export type TreeItem = WorkspaceTreeItem | NamespaceTreeItem | TaskTreeItem;

export class WorkspaceTreeItem extends vscode.TreeItem {
private static readonly icon = 'folder';
constructor(
readonly label: string,
readonly workspace: string,
readonly tasks: Task[],
readonly namespace: Namespace,
readonly collapsibleState: vscode.TreeItemCollapsibleState,
readonly command?: vscode.Command
) {
super(label, collapsibleState);
this.description = this.workspace;
this.iconPath = new vscode.ThemeIcon('folder', new vscode.ThemeColor('vscodetask.workspaceIcon'));
this.iconPath = new vscode.ThemeIcon(
WorkspaceTreeItem.icon,
new vscode.ThemeColor('vscodetask.workspaceIcon')
);
this.contextValue = `workspaceTreeItem`;
}
}

export class NamespaceTreeItem extends vscode.TreeItem {
private static readonly icon = 'symbol-namespace';
constructor(
readonly label: string,
readonly workspace: string,
readonly namespaceMap: any,
readonly tasks: Task[],
readonly namespace: Namespace,
readonly collapsibleState: vscode.TreeItemCollapsibleState,
readonly command?: vscode.Command
) {
super(label, collapsibleState);
this.iconPath = new vscode.ThemeIcon('symbol-namespace', new vscode.ThemeColor('vscodetask.namespaceIcon'));
this.iconPath = new vscode.ThemeIcon(
NamespaceTreeItem.icon,
new vscode.ThemeColor('vscodetask.namespaceIcon')
);
this.contextValue = `namespaceTreeItem`;
}
}

export class TaskTreeItem extends vscode.TreeItem {
private static readonly icon = 'symbol-function';
constructor(
readonly label: string,
readonly workspace: string,
Expand All @@ -43,10 +51,24 @@ export class TaskTreeItem extends vscode.TreeItem {
) {
super(label, collapsibleState);
this.description = this.task?.desc;
if (this.task.up_to_date) {
this.iconPath = new vscode.ThemeIcon('debug-breakpoint-log-unverified', new vscode.ThemeColor('vscodetask.upToDateIcon'));
} else {
this.iconPath = new vscode.ThemeIcon('debug-breakpoint-data-unverified', new vscode.ThemeColor('vscodetask.outOfDateIcon'));
switch (this.task.up_to_date) {
case true:
this.iconPath = new vscode.ThemeIcon(
TaskTreeItem.icon,
new vscode.ThemeColor('vscodetask.upToDateIcon')
);
break;
case false:
this.iconPath = new vscode.ThemeIcon(
TaskTreeItem.icon,
new vscode.ThemeColor('vscodetask.outOfDateIcon')
);
break;
default:
this.iconPath = new vscode.ThemeIcon(
TaskTreeItem.icon,
new vscode.ThemeColor('vscodetask.primaryColor')
);
}
this.contextValue = `taskTreeItem`;
}
Expand Down
9 changes: 3 additions & 6 deletions src/models/taskfile.ts → src/models/models.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
export type TaskMapping = {
[key: string]: TaskMapping | null;
};

export interface Taskfile {
export interface Namespace {
tasks: Task[];
namespaces: Map<string, Namespace>;
location: string; // The location of the actual Taskfile
// The vscode workspace directory where the command was executed to find this taskfile
// This is where tasks in this taskfile will be executed from.
Expand All @@ -15,7 +12,7 @@ export interface Task {
desc: string;
summary: string;
// eslint-disable-next-line @typescript-eslint/naming-convention
up_to_date: boolean;
up_to_date: boolean | undefined;
location: Location;
}

Expand Down
Loading
Loading