mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 10:19:02 +00:00
Merge pull request #193486 from microsoft/merogge/task-reconnection
fire `onDidReconnectToTasks` when there are no task terminals to reconnect to so tasks run on `folderOpen`
This commit is contained in:
@@ -231,6 +231,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
|||||||
public onDidChangeTaskSystemInfo: Event<void> = this._onDidChangeTaskSystemInfo.event;
|
public onDidChangeTaskSystemInfo: Event<void> = this._onDidChangeTaskSystemInfo.event;
|
||||||
private _onDidReconnectToTasks: Emitter<void> = new Emitter();
|
private _onDidReconnectToTasks: Emitter<void> = new Emitter();
|
||||||
public onDidReconnectToTasks: Event<void> = this._onDidReconnectToTasks.event;
|
public onDidReconnectToTasks: Event<void> = this._onDidReconnectToTasks.event;
|
||||||
|
public get isReconnected(): boolean { return this._tasksReconnected; }
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
||||||
@@ -349,6 +350,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
|||||||
this._attemptTaskReconnection();
|
this._attemptTaskReconnection();
|
||||||
} else {
|
} else {
|
||||||
this._tasksReconnected = true;
|
this._tasksReconnected = true;
|
||||||
|
this._onDidReconnectToTasks.fire();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,19 +28,18 @@ export class RunAutomaticTasks extends Disposable implements IWorkbenchContribut
|
|||||||
@IWorkspaceTrustManagementService private readonly _workspaceTrustManagementService: IWorkspaceTrustManagementService,
|
@IWorkspaceTrustManagementService private readonly _workspaceTrustManagementService: IWorkspaceTrustManagementService,
|
||||||
@ILogService private readonly _logService: ILogService) {
|
@ILogService private readonly _logService: ILogService) {
|
||||||
super();
|
super();
|
||||||
this._taskService.onDidReconnectToTasks((() => {
|
if (this._taskService.isReconnected) {
|
||||||
if (this._workspaceTrustManagementService.isWorkspaceTrusted()) {
|
|
||||||
this._tryRunTasks();
|
this._tryRunTasks();
|
||||||
|
} else {
|
||||||
|
this._register(Event.once(this._taskService.onDidReconnectToTasks)(async () => await this._tryRunTasks()));
|
||||||
}
|
}
|
||||||
}));
|
this._register(this._workspaceTrustManagementService.onDidChangeTrust(async () => await this._tryRunTasks()));
|
||||||
this._register(this._workspaceTrustManagementService.onDidChangeTrust(async trusted => {
|
|
||||||
if (trusted) {
|
|
||||||
await this._tryRunTasks();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _tryRunTasks() {
|
private async _tryRunTasks() {
|
||||||
|
if (!this._workspaceTrustManagementService.isWorkspaceTrusted()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this._hasRunTasks || this._configurationService.getValue(ALLOW_AUTOMATIC_TASKS) === 'off') {
|
if (this._hasRunTasks || this._configurationService.getValue(ALLOW_AUTOMATIC_TASKS) === 'off') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ export interface IWorkspaceFolderTaskResult extends IWorkspaceTaskResult {
|
|||||||
export interface ITaskService {
|
export interface ITaskService {
|
||||||
readonly _serviceBrand: undefined;
|
readonly _serviceBrand: undefined;
|
||||||
onDidStateChange: Event<ITaskEvent>;
|
onDidStateChange: Event<ITaskEvent>;
|
||||||
|
isReconnected: boolean;
|
||||||
onDidReconnectToTasks: Event<void>;
|
onDidReconnectToTasks: Event<void>;
|
||||||
supportsMultipleTaskExecutions: boolean;
|
supportsMultipleTaskExecutions: boolean;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user