1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-11-26 03:27:23 +03:00

ref: Eugeny/tabby/pull#8416

This commit is contained in:
Clem Fern 2023-06-15 21:07:24 +02:00
parent 2c0e50771f
commit cea5cc73ff
2 changed files with 22 additions and 5 deletions

View File

@ -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$, () => {
@ -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
*/

View File

@ -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()
}
}