diff --git a/src/vs/workbench/contrib/terminal/browser/terminalActions.ts b/src/vs/workbench/contrib/terminal/browser/terminalActions.ts index 8982c2ae0fbc1..26f8053d7d8b9 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalActions.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalActions.ts @@ -846,6 +846,19 @@ export function registerTerminalActions() { accessor.get(ITerminalService).hideFindWidget(); } }); + registerAction2(class extends Action2 { + constructor() { + super({ + id: TerminalCommandId.DetachProcess, + title: { value: localize('workbench.action.terminal.detachProcess', "Detach Process"), original: 'Detach Process' }, + f1: true, + category + }); + } + async run(accessor: ServicesAccessor) { + accessor.get(ITerminalService).doWithActiveInstance(instance => instance.detachFromProcess()); + } + }); registerAction2(class extends Action2 { constructor() { super({ diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index a80f5e4e61ff1..279f805f31d33 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -984,6 +984,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { detachFromProcess(): void { this._processManager.detachFromProcess(); + this.dispose(); } forceRedraw(): void { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts b/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts index 5642ec8b3ddca..f09749a30568a 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts @@ -176,6 +176,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce detachFromProcess(): void { this._process?.detach?.(); + this._process = null; } async createProcess( diff --git a/src/vs/workbench/contrib/terminal/common/terminal.ts b/src/vs/workbench/contrib/terminal/common/terminal.ts index 0d6f364ce3b82..a0a7a2599e8ed 100644 --- a/src/vs/workbench/contrib/terminal/common/terminal.ts +++ b/src/vs/workbench/contrib/terminal/common/terminal.ts @@ -447,7 +447,8 @@ export const enum TerminalCommandId { NavigationModeFocusPrevious = 'workbench.action.terminal.navigationModeFocusPrevious', ShowEnvironmentInformation = 'workbench.action.terminal.showEnvironmentInformation', SearchWorkspace = 'workbench.action.terminal.searchWorkspace', - AttachToRemoteTerminal = 'workbench.action.terminal.attachToSession' + AttachToRemoteTerminal = 'workbench.action.terminal.attachToSession', + DetachProcess = 'workbench.action.terminal.detachProcess' } export const DEFAULT_COMMANDS_TO_SKIP_SHELL: string[] = [