Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

check if it is restarting before removing persistent task #157531

Merged
merged 1 commit into from Aug 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts
Expand Up @@ -87,7 +87,7 @@ import { IWorkspaceTrustManagementService, IWorkspaceTrustRequestService } from
import { VirtualWorkspaceContext } from 'vs/workbench/common/contextkeys';
import { Schemas } from 'vs/base/common/network';
import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/browser/panecomposite';
import { ILifecycleService, StartupKind } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { ILifecycleService, ShutdownReason, StartupKind } from 'vs/workbench/services/lifecycle/common/lifecycle';

const QUICKOPEN_HISTORY_LIMIT_CONFIG = 'task.quickOpen.history';
const PROBLEM_MATCHER_NEVER_CONFIG = 'task.problemMatchers.neverPrompt';
Expand Down Expand Up @@ -230,6 +230,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
private _waitForSupportedExecutions: Promise<void>;
private _onDidRegisterSupportedExecutions: Emitter<void> = new Emitter();
private _onDidChangeTaskSystemInfo: Emitter<void> = new Emitter();
private _willRestart: boolean = false;
public onDidChangeTaskSystemInfo: Event<void> = this._onDidChangeTaskSystemInfo.event;

constructor(
Expand Down Expand Up @@ -322,10 +323,15 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
}
return task._label;
});
this._lifecycleService.onBeforeShutdown(e => {
this._willRestart = e.reason !== ShutdownReason.RELOAD;
});
this._register(this.onDidStateChange(e => {
const key = e.__task?.getRecentlyUsedKey();
if (e.kind === TaskEventKind.Terminated && key) {
this.removePersistentTask(key);
if (this._willRestart) {
const key = e.__task?.getRecentlyUsedKey();
if (e.kind === TaskEventKind.Terminated && key) {
this.removePersistentTask(key);
}
}
}));
this._waitForSupportedExecutions = new Promise(resolve => {
Expand Down