mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Merge pull request #168887 from jeanp413/fix-168643
Fixes editor-area terminals are not restored after quit
This commit is contained in:
commit
cb1113ac32
|
@ -479,11 +479,6 @@ export interface ITerminalInstance {
|
|||
*/
|
||||
readonly persistentProcessId: number | undefined;
|
||||
|
||||
/**
|
||||
* The id of a persistent process during the shutdown process
|
||||
*/
|
||||
shutdownPersistentProcessId: number | undefined;
|
||||
|
||||
/**
|
||||
* Whether the process should be persisted across reloads.
|
||||
*/
|
||||
|
|
|
@ -15,7 +15,7 @@ import { getColorClass, getUriClasses } from 'vs/workbench/contrib/terminal/brow
|
|||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IShellLaunchConfig, TerminalExitReason, TerminalLocation, TerminalSettingId } from 'vs/platform/terminal/common/terminal';
|
||||
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||
import { ILifecycleService, ShutdownReason, WillShutdownEvent } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||
import { ConfirmOnKill } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
@ -177,9 +177,17 @@ export class TerminalEditorInput extends EditorInput implements IEditorCloseHand
|
|||
|
||||
// Don't dispose editor when instance is torn down on shutdown to avoid extra work and so
|
||||
// the editor/tabs don't disappear
|
||||
this._lifecycleService.onWillShutdown(() => {
|
||||
this._lifecycleService.onWillShutdown((e: WillShutdownEvent) => {
|
||||
this._isShuttingDown = true;
|
||||
dispose(disposeListeners);
|
||||
|
||||
// Don't touch processes if the shutdown was a result of reload as they will be reattached
|
||||
const shouldPersistTerminals = this._configurationService.getValue<boolean>(TerminalSettingId.EnablePersistentSessions) && e.reason === ShutdownReason.RELOAD;
|
||||
if (shouldPersistTerminals) {
|
||||
instance.detachProcessAndDispose(TerminalExitReason.Shutdown);
|
||||
} else {
|
||||
instance.dispose(TerminalExitReason.Shutdown);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -144,7 +144,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
|||
|
||||
readonly _processManager: ITerminalProcessManager;
|
||||
private readonly _resource: URI;
|
||||
private _shutdownPersistentProcessId: number | undefined;
|
||||
// Enables disposal of the xterm onKey
|
||||
// event when the CwdDetection capability
|
||||
// is added
|
||||
|
@ -720,11 +719,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
|||
return TerminalInstance._lastKnownCanvasDimensions;
|
||||
}
|
||||
|
||||
set shutdownPersistentProcessId(shutdownPersistentProcessId: number | undefined) {
|
||||
this._shutdownPersistentProcessId = shutdownPersistentProcessId;
|
||||
}
|
||||
get persistentProcessId(): number | undefined { return this._processManager.persistentProcessId ?? this._shutdownPersistentProcessId; }
|
||||
get shouldPersist(): boolean { return (this._processManager.shouldPersist || this._shutdownPersistentProcessId !== undefined) && !this.shellLaunchConfig.isTransient && (!this.reconnectionProperties || this._configurationService.getValue(TaskSettingId.Reconnection) === true); }
|
||||
get persistentProcessId(): number | undefined { return this._processManager.persistentProcessId; }
|
||||
get shouldPersist(): boolean { return this._processManager.shouldPersist && !this.shellLaunchConfig.isTransient && (!this.reconnectionProperties || this._configurationService.getValue(TaskSettingId.Reconnection) === true); }
|
||||
|
||||
/**
|
||||
* Create xterm.js instance and attach data listeners.
|
||||
|
|
|
@ -631,18 +631,14 @@ export class TerminalService implements ITerminalService {
|
|||
// Don't touch processes if the shutdown was a result of reload as they will be reattached
|
||||
const shouldPersistTerminals = this._configHelper.config.enablePersistentSessions && e.reason === ShutdownReason.RELOAD;
|
||||
if (shouldPersistTerminals) {
|
||||
for (const instance of this.instances) {
|
||||
for (const instance of this._terminalGroupService.instances) {
|
||||
instance.detachProcessAndDispose(TerminalExitReason.Shutdown);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Force dispose of all terminal instances
|
||||
const shouldPersistTerminalsForEvent = this._shouldReviveProcesses(e.reason);
|
||||
for (const instance of this.instances) {
|
||||
if (shouldPersistTerminalsForEvent) {
|
||||
instance.shutdownPersistentProcessId = instance.persistentProcessId;
|
||||
}
|
||||
// Force dispose of all pane terminal instances
|
||||
for (const instance of this._terminalGroupService.instances) {
|
||||
instance.dispose(TerminalExitReason.Shutdown);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue