diff --git a/tabby-terminal/src/api/baseTerminalTab.component.ts b/tabby-terminal/src/api/baseTerminalTab.component.ts index a5285293..450f4644 100644 --- a/tabby-terminal/src/api/baseTerminalTab.component.ts +++ b/tabby-terminal/src/api/baseTerminalTab.component.ts @@ -772,10 +772,7 @@ export class BaseTerminalTabComponent
extends Bas }) this.attachSessionHandler(this.session.closed$, () => { - const behavior = this.profile.behaviorOnSessionEnd - if (destroyOnSessionClose || behavior === 'close' || behavior === 'auto' && this.isSessionExplicitlyTerminated()) { - this.destroy() - } + this.onSessionClosed(destroyOnSessionClose) }) this.attachSessionHandler(this.session.destroyed$, () => { @@ -788,6 +785,26 @@ export class BaseTerminalTabComponent
extends Bas }) } + /** + * Method called when session is closed. + */ + protected onSessionClosed (destroyOnSessionClose = false): void { + if (destroyOnSessionClose || this.doesTabShouldBeDestroyedOnSessionClosed()) { + this.destroy() + } + } + + /** + * Return true if tab should be destroyed on session closed. + */ + protected doesTabShouldBeDestroyedOnSessionClosed (): boolean { + const behavior = this.profile.behaviorOnSessionEnd + if (behavior === 'close' || behavior === 'auto' && this.isSessionExplicitlyTerminated()) { + return true + } + return false + } + /** * Method called when session is destroyed. Set the session to null */ diff --git a/tabby-terminal/src/api/connectableTerminalTab.component.ts b/tabby-terminal/src/api/connectableTerminalTab.component.ts index 0d63ff2d..ca2e6ba2 100644 --- a/tabby-terminal/src/api/connectableTerminalTab.component.ts +++ b/tabby-terminal/src/api/connectableTerminalTab.component.ts @@ -55,7 +55,7 @@ export abstract class ConnectableTerminalTabComponent