Skip to content

Commit d842be4

Browse files
authored
fix task issue (#263)
1 parent 5a79e87 commit d842be4

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/platform/tasks/vscode/tasksService.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@ export class TasksService extends DisposableStore implements ITasksService {
7878
for (const [key, terminal] of this.latestTerminalForTaskDefinition.entries()) {
7979
if (key.id) {
8080
// Only some task definitions have IDs
81-
const taskId = this._getTaskId(key);
81+
const taskId = this._getTaskId(taskDefinition);
8282
if (taskId === key.id) {
8383
return terminal;
8484
}
8585
}
8686
if ((taskDefinition.type === key.type &&
87+
(key.label || key.script || key.command) &&
8788
(!key.label || taskDefinition.label === key.label) &&
8889
(!key.script || taskDefinition.script === key.script) &&
8990
(!key.command || taskDefinition.command === key.command))) {
@@ -93,20 +94,11 @@ export class TasksService extends DisposableStore implements ITasksService {
9394
this.logService.logger.debug(`getTerminalForTask: current stored terminals: ${[...this.latestTerminalForTaskDefinition.values()].map(t => t.name).join(', ')}`);
9495
}
9596
}
96-
// This comes from: src/vs/workbench/contrib/tasks/common/tasks.ts#L1296-L1317
9797
private _getTaskId(taskDefinition: vscode.TaskDefinition): string | undefined {
98-
const keys = Object.keys(taskDefinition).sort();
99-
let result: string = '';
100-
for (const key of keys) {
101-
let stringified = taskDefinition[key];
102-
if (stringified instanceof Object) {
103-
stringified = this._getTaskId(stringified);
104-
} else if (typeof stringified === 'string') {
105-
stringified = stringified.replace(/,/g, ',,');
106-
}
107-
result += key + ',' + stringified + ',';
98+
if (!taskDefinition.type || (taskDefinition.command === undefined && taskDefinition.script === undefined)) {
99+
return undefined;
108100
}
109-
return result;
101+
return taskDefinition.type + ',' + (taskDefinition.command ?? taskDefinition.script) + ',';
110102
}
111103

112104
async getTaskConfigPosition(workspaceFolder: URI, def: vscode.TaskDefinition) {

0 commit comments

Comments
 (0)