Skip to content

Commit 2d8c5fe

Browse files
committed
[Compatibility] Apply default to missing 'task.scope'
The 'vscode.api' for creation of tasks has two constructors, one of them deprecated which does not require the 'scope' parameter. Some extensions (e.g., Jake) still use the deprecated api and therefore it is possible to receive 'Task's where 'scope' is undefined and causes an exception in 'Theia' which prevents the use of the related tasks. This change fixes it by using 'TaskScope.Workspace' as a default in such cases. Signed-off-by: Alvaro Sanchez-Leon <[email protected]>
1 parent 8678018 commit 2d8c5fe

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/plugin-ext/src/plugin/type-converters.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -835,10 +835,12 @@ export function fromTask(task: theia.Task): TaskDto | undefined {
835835
if ('detail' in task) {
836836
taskDto.detail = task.detail;
837837
}
838-
if (typeof task.scope === 'object') {
839-
taskDto.scope = task.scope.uri.toString();
840-
} else if (typeof task.scope === 'number') {
838+
if (typeof task.scope === 'number') {
841839
taskDto.scope = task.scope;
840+
} else if (task.scope !== undefined) {
841+
taskDto.scope = task.scope.uri.toString();
842+
} else {
843+
taskDto.scope = types.TaskScope.Workspace;
842844
}
843845

844846
if (task.presentationOptions) {

0 commit comments

Comments
 (0)