Skip to content

Commit

Permalink
ref: Eugeny/tabby/pull#8416
Browse files Browse the repository at this point in the history
  • Loading branch information
Clem-Fern committed Jun 15, 2023
1 parent 2c0e507 commit cea5cc7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
25 changes: 21 additions & 4 deletions tabby-terminal/src/api/baseTerminalTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,10 +772,7 @@ export class BaseTerminalTabComponent<P extends BaseTerminalProfile> 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$, () => {
Expand All @@ -788,6 +785,26 @@ export class BaseTerminalTabComponent<P extends BaseTerminalProfile> 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
*/
Expand Down
2 changes: 1 addition & 1 deletion tabby-terminal/src/api/connectableTerminalTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export abstract class ConnectableTerminalTabComponent<P extends BaseTerminalProf
if (this.frontend) {
if (this.profile.behaviorOnSessionEnd === 'reconnect') {
this.reconnect()
} else if (this.profile.behaviorOnSessionEnd === 'keep' || this.profile.behaviorOnSessionEnd === 'auto' && !this.isSessionExplicitlyTerminated()) {
} else if (this.profile.behaviorOnSessionEnd === 'keep' || !this.doesTabShouldBeDestroyedOnSessionClosed()) {
this.offerReconnection()
}
}
Expand Down

0 comments on commit cea5cc7

Please sign in to comment.