From 46d8d3aa69e8cade0d3ef14f1caee86cb51121d1 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Tue, 17 Mar 2020 16:37:01 +0100 Subject: [PATCH] Tasks without command are added to instances Part of #92792 --- .../tasks/browser/terminalTaskSystem.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts index 99c961b924a..969c0f9c1ea 100644 --- a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts +++ b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts @@ -33,7 +33,7 @@ import { IOutputService } from 'vs/workbench/contrib/output/common/output'; import { StartStopProblemCollector, WatchingProblemCollector, ProblemCollectorEventKind, ProblemHandlingStrategy } from 'vs/workbench/contrib/tasks/common/problemCollectors'; import { Task, CustomTask, ContributedTask, RevealKind, CommandOptions, ShellConfiguration, RuntimeType, PanelKind, - TaskEvent, TaskEventKind, ShellQuotingOptions, ShellQuoting, CommandString, CommandConfiguration, ExtensionTaskSource, TaskScope, RevealProblemKind, DependsOrder, TaskSourceKind + TaskEvent, TaskEventKind, ShellQuotingOptions, ShellQuoting, CommandString, CommandConfiguration, ExtensionTaskSource, TaskScope, RevealProblemKind, DependsOrder, TaskSourceKind, InMemoryTask } from 'vs/workbench/contrib/tasks/common/tasks'; import { ITaskSystem, ITaskSummary, ITaskExecuteResult, TaskExecuteKind, TaskError, TaskErrors, ITaskResolver, @@ -250,10 +250,12 @@ export class TerminalTaskSystem implements ITaskSystem { executeResult.promise.then(summary => { this.lastTask = this.currentTask; }); - if (!this.instances[commonKey]) { - this.instances[commonKey] = new InstanceManager(); + if (InMemoryTask.is(task) || !this.isTaskEmpty(task)) { + if (!this.instances[commonKey]) { + this.instances[commonKey] = new InstanceManager(); + } + this.instances[commonKey].addInstance(); } - this.instances[commonKey].addInstance(); return executeResult; } catch (error) { if (error instanceof TaskError) { @@ -606,8 +608,7 @@ export class TerminalTaskSystem implements ITaskSystem { const resolvedVariables = this.resolveVariablesFromSet(systemInfo, workspaceFolder, task, variables, alreadyResolved); return resolvedVariables.then((resolvedVariables) => { - const isCustomExecution = (task.command.runtime === RuntimeType.CustomExecution); - if (resolvedVariables && (task.command !== undefined) && task.command.runtime && (isCustomExecution || (task.command.name !== undefined))) { + if (resolvedVariables && !this.isTaskEmpty(task)) { this.currentTask.resolvedVariables = resolvedVariables; return this.executeInTerminal(task, trigger, new VariableResolver(workspaceFolder, systemInfo, resolvedVariables.variables, this.configurationResolverService), workspaceFolder); } else { @@ -620,6 +621,11 @@ export class TerminalTaskSystem implements ITaskSystem { }); } + private isTaskEmpty(task: CustomTask | ContributedTask): boolean { + const isCustomExecution = (task.command.runtime === RuntimeType.CustomExecution); + return !((task.command !== undefined) && task.command.runtime && (isCustomExecution || (task.command.name !== undefined))); + } + private reexecuteCommand(task: CustomTask | ContributedTask, trigger: string, alreadyResolved: Map): Promise { const lastTask = this.lastTask; if (!lastTask) { -- GitLab