Support detach from process in remote

Part of #118276
This commit is contained in:
Daniel Imms 2021-06-16 05:52:54 -07:00
parent 16facd8645
commit 152d4226e6
7 changed files with 23 additions and 7 deletions

View file

@ -68,6 +68,11 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
return undefined;
}
async detach(): Promise<void> {
await this._startBarrier.wait();
return this._remoteTerminalChannel.detachFromProcess(this.id);
}
shutdown(immediate: boolean): void {
this._startBarrier.wait().then(_ => {
this._remoteTerminalChannel.shutdown(this._id, immediate);

View file

@ -490,7 +490,7 @@ export interface ITerminalInstance {
/**
* Inform the process that the terminal is now detached.
*/
detachFromProcess(): void;
detachFromProcess(): Promise<void>;
/**
* Forces the terminal to redraw its viewport.

View file

@ -904,7 +904,8 @@ export function registerTerminalActions() {
});
}
async run(accessor: ServicesAccessor) {
accessor.get(ITerminalService).doWithActiveInstance(instance => instance.detachFromProcess());
const terminalService = accessor.get(ITerminalService);
await terminalService.getActiveInstance()?.detachFromProcess();
}
});
registerAction2(class extends Action2 {

View file

@ -984,8 +984,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
super.dispose();
}
detachFromProcess(): void {
this._processManager.detachFromProcess();
async detachFromProcess(): Promise<void> {
await this._processManager.detachFromProcess();
this.dispose();
}

View file

@ -174,8 +174,15 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
});
}
detachFromProcess(): void {
this._process?.detach?.();
async detachFromProcess(): Promise<void> {
if (!this._process) {
return;
}
if (this._process.detach) {
await this._process.detach();
} else {
throw new Error('This terminal process does not support detaching');
}
this._process = null;
}

View file

@ -198,6 +198,9 @@ export class RemoteTerminalChannelClient {
attachToProcess(id: number): Promise<void> {
return this._channel.call('$attachToProcess', [id]);
}
detachFromProcess(id: number): Promise<void> {
return this._channel.call('$detachFromProcess', [id]);
}
listProcesses(): Promise<IProcessDetails[]> {
return this._channel.call('$listProcesses');
}

View file

@ -297,7 +297,7 @@ export interface ITerminalProcessManager extends IDisposable {
readonly onEnvironmentVariableInfoChanged: Event<IEnvironmentVariableInfo>;
dispose(immediate?: boolean): void;
detachFromProcess(): void;
detachFromProcess(): 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): void;