Skip to content

Commit ff358d7

Browse files
authored
Merge pull request microsoft#187322 from microsoft/merogge/fix-task-reconnection
2 parents 84fc1ff + 61b0c4f commit ff358d7

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfile
4747
import { ITerminalGroupService, ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
4848
import { ITerminalProfileResolverService } from 'vs/workbench/contrib/terminal/common/terminal';
4949

50-
import { ConfiguringTask, ContributedTask, CustomTask, ExecutionEngine, InMemoryTask, ITaskEvent, ITaskIdentifier, ITaskSet, JsonSchemaVersion, KeyedTaskIdentifier, RuntimeType, Task, TaskDefinition, TaskEventKind, TaskGroup, TaskRunSource, TaskSettingId, TaskSorter, TaskSourceKind, TasksSchemaProperties, TASK_RUNNING_STATE, USER_TASKS_GROUP_KEY } from 'vs/workbench/contrib/tasks/common/tasks';
50+
import { ConfiguringTask, ContributedTask, CustomTask, ExecutionEngine, InMemoryTask, ITaskEvent, ITaskIdentifier, ITaskSet, JsonSchemaVersion, KeyedTaskIdentifier, RuntimeType, Task, TASK_RUNNING_STATE, TaskDefinition, TaskEventKind, TaskGroup, TaskRunSource, TaskSettingId, TaskSorter, TaskSourceKind, TasksSchemaProperties, USER_TASKS_GROUP_KEY } from 'vs/workbench/contrib/tasks/common/tasks';
5151
import { CustomExecutionSupportedContext, ICustomizationProperties, IProblemMatcherRunOptions, ITaskFilter, ITaskProvider, ITaskService, IWorkspaceFolderTaskResult, ProcessExecutionSupportedContext, ServerlessWebContext, ShellExecutionSupportedContext, TaskCommandsRegistered, TaskExecutionSupportedContext } from 'vs/workbench/contrib/tasks/common/taskService';
5252
import { ITaskExecuteResult, ITaskResolver, ITaskSummary, ITaskSystem, ITaskSystemInfo, ITaskTerminateResponse, TaskError, TaskErrors, TaskExecuteKind } from 'vs/workbench/contrib/tasks/common/taskSystem';
5353
import { getTemplates as getTaskTemplates } from 'vs/workbench/contrib/tasks/common/taskTemplates';
@@ -60,15 +60,18 @@ import { IQuickInputService, IQuickPick, IQuickPickItem, IQuickPickSeparator, Qu
6060
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
6161
import { TaskDefinitionRegistry } from 'vs/workbench/contrib/tasks/common/taskDefinitionRegistry';
6262

63+
import { raceTimeout } from 'vs/base/common/async';
6364
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
6465
import { once } from 'vs/base/common/functional';
6566
import { toFormattedString } from 'vs/base/common/jsonFormatter';
6667
import { Schemas } from 'vs/base/common/network';
68+
import { ThemeIcon } from 'vs/base/common/themables';
6769
import { IResolvedTextEditorModel, ITextModelService } from 'vs/editor/common/services/resolverService';
6870
import { TextEditorSelectionRevealType } from 'vs/platform/editor/common/editor';
71+
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
6972
import { ILogService } from 'vs/platform/log/common/log';
73+
import { TerminalExitReason } from 'vs/platform/terminal/common/terminal';
7074
import { IThemeService } from 'vs/platform/theme/common/themeService';
71-
import { ThemeIcon } from 'vs/base/common/themables';
7275
import { IWorkspaceTrustManagementService, IWorkspaceTrustRequestService } from 'vs/platform/workspace/common/workspaceTrust';
7376
import { VirtualWorkspaceContext } from 'vs/workbench/common/contextkeys';
7477
import { EditorResourceAccessor, SaveReason } from 'vs/workbench/common/editor';
@@ -79,10 +82,7 @@ import { ILifecycleService, ShutdownReason, StartupKind } from 'vs/workbench/ser
7982
import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/browser/panecomposite';
8083
import { IPathService } from 'vs/workbench/services/path/common/pathService';
8184
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
82-
import { TerminalExitReason } from 'vs/platform/terminal/common/terminal';
8385
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
84-
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
85-
import { raceTimeout } from 'vs/base/common/async';
8686

8787
const QUICKOPEN_HISTORY_LIMIT_CONFIG = 'task.quickOpen.history';
8888
const PROBLEM_MATCHER_NEVER_CONFIG = 'task.problemMatchers.neverPrompt';
@@ -223,8 +223,10 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
223223

224224
protected _outputChannel: IOutputChannel;
225225
protected readonly _onDidStateChange: Emitter<ITaskEvent>;
226-
private _waitForSupportedExecutions: Promise<void>;
226+
private _waitForOneSupportedExecution: Promise<void>;
227+
private _waitForAllSupportedExecutions: Promise<void>;
227228
private _onDidRegisterSupportedExecutions: Emitter<void> = new Emitter();
229+
private _onDidRegisterAllSupportedExecutions: Emitter<void> = new Emitter();
228230
private _onDidChangeTaskSystemInfo: Emitter<void> = new Emitter();
229231
private _willRestart: boolean = false;
230232
public onDidChangeTaskSystemInfo: Event<void> = this._onDidChangeTaskSystemInfo.event;
@@ -333,9 +335,12 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
333335
this._setPersistentTask(e.__task);
334336
}
335337
}));
336-
this._waitForSupportedExecutions = new Promise(resolve => {
338+
this._waitForOneSupportedExecution = new Promise(resolve => {
337339
once(this._onDidRegisterSupportedExecutions.event)(() => resolve());
338340
});
341+
this._waitForAllSupportedExecutions = new Promise(resolve => {
342+
once(this._onDidRegisterAllSupportedExecutions.event)(() => resolve());
343+
});
339344
if (this._terminalService.getReconnectedTerminals('Task')?.length) {
340345
this._attemptTaskReconnection();
341346
} else {
@@ -365,6 +370,9 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
365370
// update tasks so an incomplete list isn't returned when getWorkspaceTasks is called
366371
this._workspaceTasksPromise = undefined;
367372
this._onDidRegisterSupportedExecutions.fire();
373+
if (custom && shell && process) {
374+
this._onDidRegisterAllSupportedExecutions.fire();
375+
}
368376
}
369377

370378
private _attemptTaskReconnection(): void {
@@ -2201,7 +2209,12 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
22012209
if (!(await this._trust())) {
22022210
return new Map();
22032211
}
2204-
await this._waitForSupportedExecutions;
2212+
await this._waitForOneSupportedExecution;
2213+
if (runSource === TaskRunSource.Reconnect) {
2214+
await raceTimeout(this._waitForAllSupportedExecutions, 2000, () => {
2215+
this._logService.warn('Timed out waiting for all supported executions for task reconnection');
2216+
});
2217+
}
22052218
await this._whenTaskSystemReady;
22062219
if (this._workspaceTasksPromise) {
22072220
return this._workspaceTasksPromise;
@@ -2878,7 +2891,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
28782891
/**
28792892
*
28802893
* @param tasks - The tasks which need to be filtered
2881-
* @param taskGlobsInList - This tells splitPerGroupType to filter out globbed tasks (into defaults)
2894+
* @param tasksInList - This tells splitPerGroupType to filter out globbed tasks (into defaults)
28822895
* @returns
28832896
*/
28842897
private _getDefaultTasks(tasks: Task[], taskGlobsInList: boolean = false): Task[] {

0 commit comments

Comments
 (0)