mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 19:12:57 +00:00
Merge pull request #158604 from microsoft/tyriar/158595
Only persist terminals when they have had interaction
This commit is contained in:
commit
0380d81838
9 changed files with 23 additions and 20 deletions
|
@ -297,7 +297,7 @@ export interface IPtyService extends IPtyHostController {
|
|||
workspaceName: string
|
||||
): Promise<number>;
|
||||
attachToProcess(id: number): Promise<void>;
|
||||
detachFromProcess(id: number): Promise<void>;
|
||||
detachFromProcess(id: number, forcePersist?: boolean): Promise<void>;
|
||||
|
||||
/**
|
||||
* Lists all orphaned processes, ie. those without a connected frontend.
|
||||
|
@ -642,8 +642,9 @@ export interface ITerminalChildProcess {
|
|||
|
||||
/**
|
||||
* Detach the process from the UI and await reconnect.
|
||||
* @param forcePersist Whether to force the process to persist if it supports persistence.
|
||||
*/
|
||||
detach?(): Promise<void>;
|
||||
detach?(forcePersist?: boolean): Promise<void>;
|
||||
|
||||
/**
|
||||
* Shutdown the terminal process.
|
||||
|
|
|
@ -229,8 +229,8 @@ export class PtyHostService extends Disposable implements IPtyService {
|
|||
attachToProcess(id: number): Promise<void> {
|
||||
return this._proxy.attachToProcess(id);
|
||||
}
|
||||
detachFromProcess(id: number): Promise<void> {
|
||||
return this._proxy.detachFromProcess(id);
|
||||
detachFromProcess(id: number, forcePersist?: boolean): Promise<void> {
|
||||
return this._proxy.detachFromProcess(id, forcePersist);
|
||||
}
|
||||
listProcesses(): Promise<IProcessDetails[]> {
|
||||
return this._proxy.listProcesses();
|
||||
|
|
|
@ -236,8 +236,8 @@ export class PtyService extends Disposable implements IPtyService {
|
|||
return this._throwIfNoPty(id).updateProperty(type, value);
|
||||
}
|
||||
|
||||
async detachFromProcess(id: number): Promise<void> {
|
||||
return this._throwIfNoPty(id).detach();
|
||||
async detachFromProcess(id: number, forcePersist?: boolean): Promise<void> {
|
||||
return this._throwIfNoPty(id).detach(forcePersist);
|
||||
}
|
||||
|
||||
async reduceConnectionGraceTime(): Promise<void> {
|
||||
|
@ -595,9 +595,11 @@ export class PersistentTerminalProcess extends Disposable {
|
|||
this._disconnectRunner2.cancel();
|
||||
}
|
||||
|
||||
async detach(): Promise<void> {
|
||||
this._logService.trace('persistentTerminalProcess#detach', this._persistentProcessId);
|
||||
if (this.shouldPersistTerminal) {
|
||||
async detach(forcePersist?: boolean): Promise<void> {
|
||||
this._logService.trace('persistentTerminalProcess#detach', this._persistentProcessId, forcePersist);
|
||||
// Keep the process around if it was indicated to persist and it has had some iteraction or
|
||||
// was replayed
|
||||
if (this.shouldPersistTerminal && (this._interactionState !== InteractionState.None || forcePersist)) {
|
||||
this._disconnectRunner1.schedule();
|
||||
} else {
|
||||
this.shutdown(true);
|
||||
|
|
|
@ -76,9 +76,9 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
async detach(): Promise<void> {
|
||||
async detach(forcePersist?: boolean): Promise<void> {
|
||||
await this._startBarrier.wait();
|
||||
return this._remoteTerminalChannel.detachFromProcess(this.id);
|
||||
return this._remoteTerminalChannel.detachFromProcess(this.id, forcePersist);
|
||||
}
|
||||
|
||||
shutdown(immediate: boolean): void {
|
||||
|
|
|
@ -1482,8 +1482,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
|||
|
||||
async detachProcessAndDispose(reason: TerminalExitReason): Promise<void> {
|
||||
// Detach the process and dispose the instance, without the instance dispose the terminal
|
||||
// won't go away
|
||||
await this._processManager.detachFromProcess();
|
||||
// won't go away. Force persist if the detach was requested by the user (not shutdown).
|
||||
await this._processManager.detachFromProcess(reason === TerminalExitReason.User);
|
||||
this.dispose(reason);
|
||||
}
|
||||
|
||||
|
|
|
@ -195,8 +195,8 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
|
|||
});
|
||||
}
|
||||
|
||||
async detachFromProcess(): Promise<void> {
|
||||
await this._process?.detach?.();
|
||||
async detachFromProcess(forcePersist?: boolean): Promise<void> {
|
||||
await this._process?.detach?.(forcePersist);
|
||||
this._process = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -195,8 +195,8 @@ export class RemoteTerminalChannelClient implements IPtyHostController {
|
|||
attachToProcess(id: number): Promise<void> {
|
||||
return this._channel.call('$attachToProcess', [id]);
|
||||
}
|
||||
detachFromProcess(id: number): Promise<void> {
|
||||
return this._channel.call('$detachFromProcess', [id]);
|
||||
detachFromProcess(id: number, forcePersist?: boolean): Promise<void> {
|
||||
return this._channel.call('$detachFromProcess', [id, forcePersist]);
|
||||
}
|
||||
listProcesses(): Promise<IProcessDetails[]> {
|
||||
return this._channel.call('$listProcesses');
|
||||
|
|
|
@ -398,7 +398,7 @@ export interface ITerminalProcessManager extends IDisposable {
|
|||
readonly onRestoreCommands: Event<ISerializedCommandDetectionCapability>;
|
||||
|
||||
dispose(immediate?: boolean): void;
|
||||
detachFromProcess(): Promise<void>;
|
||||
detachFromProcess(forcePersist?: boolean): Promise<void>;
|
||||
createProcess(shellLaunchConfig: IShellLaunchConfig, cols: number, rows: number, isScreenReaderModeEnabled: boolean): Promise<ITerminalLaunchError | undefined>;
|
||||
relaunch(shellLaunchConfig: IShellLaunchConfig, cols: number, rows: number, isScreenReaderModeEnabled: boolean, reset: boolean): Promise<ITerminalLaunchError | undefined>;
|
||||
write(data: string): Promise<void>;
|
||||
|
|
|
@ -52,8 +52,8 @@ export class LocalPty extends Disposable implements ITerminalChildProcess {
|
|||
start(): Promise<ITerminalLaunchError | undefined> {
|
||||
return this._localPtyService.start(this.id);
|
||||
}
|
||||
detach(): Promise<void> {
|
||||
return this._localPtyService.detachFromProcess(this.id);
|
||||
detach(forcePersist?: boolean): Promise<void> {
|
||||
return this._localPtyService.detachFromProcess(this.id, forcePersist);
|
||||
}
|
||||
shutdown(immediate: boolean): void {
|
||||
this._localPtyService.shutdown(this.id, immediate);
|
||||
|
|
Loading…
Reference in a new issue