Skip to content

Commit

Permalink
Support detaching terminal processes manually
Browse files Browse the repository at this point in the history
Part of #118276
  • Loading branch information
Tyriar committed Jun 14, 2021
1 parent 155de9d commit 8b57154
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/terminalActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {

detachFromProcess(): void {
this._processManager.detachFromProcess();
this.dispose();
}

forceRedraw(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce

detachFromProcess(): void {
this._process?.detach?.();
this._process = null;
}

async createProcess(
Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/contrib/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand Down

0 comments on commit 8b57154

Please sign in to comment.