Skip to content

Commit 6dbff8d

Browse files
committed
fix: support older versions of Task
1 parent d7439f9 commit 6dbff8d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/providers/tasks.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ export class Tasks implements vscode.TreeDataProvider<elements.TreeItem> {
3434
return Promise.resolve([]);
3535
}
3636

37-
// If the workspace folder is not the same as the taskfile location, return an empty array
38-
if (vscode.workspace.workspaceFolders[0].uri.fsPath !== path.dirname(this._taskfiles[0].location ?? "")) {
37+
// Check if the workspace folder is the same as the taskfile location.
38+
// If there is no location available (Task v3.22 or older), compare against the workspace instead.
39+
// This has the downside the tasks from Taskfiles outside of the workspace folder might be shown.
40+
if (vscode.workspace.workspaceFolders[0].uri.fsPath !== (this._taskfiles[0].location ? path.dirname(this._taskfiles[0].location) : this._taskfiles[0].workspace)) {
3941
return Promise.resolve([]);
4042
}
4143

@@ -119,7 +121,10 @@ export class Tasks implements vscode.TreeDataProvider<elements.TreeItem> {
119121
let workspaceTreeItems: elements.WorkspaceTreeItem[] = [];
120122
this._taskfiles?.forEach(taskfile => {
121123
vscode.workspace.workspaceFolders?.forEach(workspace => {
122-
if (workspace.uri.fsPath === path.dirname(taskfile.location)) {
124+
// Check if the workspace folder is the same as the taskfile location.
125+
// If there is no location available (Task v3.22 or older), compare against the workspace instead.
126+
// This has the downside the tasks from Taskfiles outside of the workspace folder might be shown.
127+
if (workspace.uri.fsPath === (taskfile.location ? path.dirname(taskfile.location) : taskfile.workspace)) {
123128
let workspaceTreeItem = new elements.WorkspaceTreeItem(
124129
workspace.name,
125130
workspace.uri.fsPath,

0 commit comments

Comments
 (0)