@@ -78,12 +78,13 @@ export class TasksService extends DisposableStore implements ITasksService {
78
78
for ( const [ key , terminal ] of this . latestTerminalForTaskDefinition . entries ( ) ) {
79
79
if ( key . id ) {
80
80
// Only some task definitions have IDs
81
- const taskId = this . _getTaskId ( key ) ;
81
+ const taskId = this . _getTaskId ( taskDefinition ) ;
82
82
if ( taskId === key . id ) {
83
83
return terminal ;
84
84
}
85
85
}
86
86
if ( ( taskDefinition . type === key . type &&
87
+ ( key . label || key . script || key . command ) &&
87
88
( ! key . label || taskDefinition . label === key . label ) &&
88
89
( ! key . script || taskDefinition . script === key . script ) &&
89
90
( ! key . command || taskDefinition . command === key . command ) ) ) {
@@ -93,20 +94,11 @@ export class TasksService extends DisposableStore implements ITasksService {
93
94
this . logService . logger . debug ( `getTerminalForTask: current stored terminals: ${ [ ...this . latestTerminalForTaskDefinition . values ( ) ] . map ( t => t . name ) . join ( ', ' ) } ` ) ;
94
95
}
95
96
}
96
- // This comes from: src/vs/workbench/contrib/tasks/common/tasks.ts#L1296-L1317
97
97
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 ;
108
100
}
109
- return result ;
101
+ return taskDefinition . type + ',' + ( taskDefinition . command ?? taskDefinition . script ) + ',' ;
110
102
}
111
103
112
104
async getTaskConfigPosition ( workspaceFolder : URI , def : vscode . TaskDefinition ) {
0 commit comments