mirror of
https://github.com/Eugeny/tabby.git
synced 2025-01-30 14:20:18 +08:00
handle split pane being closed
This commit is contained in:
parent
bcc4a262e2
commit
d25751abe7
@ -246,6 +246,23 @@ export class SplitTabComponent extends BaseTabComponent {
|
||||
})
|
||||
}
|
||||
|
||||
remove (tab: BaseTabComponent) {
|
||||
let parent = this.getParent(tab)
|
||||
let index = parent.children.indexOf(tab)
|
||||
parent.ratios.splice(index, 1)
|
||||
parent.children.splice(index, 1)
|
||||
|
||||
let ref = this.viewRefs.get(tab)
|
||||
this.viewRefs.delete(tab)
|
||||
this.viewContainer.remove(this.viewContainer.indexOf(ref))
|
||||
|
||||
this.layout()
|
||||
|
||||
if (this.root.children.length === 0) {
|
||||
this.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
addTab (tab: BaseTabComponent) {
|
||||
let ref = this.viewContainer.insert(tab.hostView) as EmbeddedViewRef<any>
|
||||
this.viewRefs.set(tab, ref)
|
||||
@ -258,6 +275,9 @@ export class SplitTabComponent extends BaseTabComponent {
|
||||
if (tab.title) {
|
||||
this.setTitle(tab.title)
|
||||
}
|
||||
tab.destroyed$.subscribe(() => {
|
||||
this.remove(tab)
|
||||
})
|
||||
}
|
||||
|
||||
navigate (dir: SplitDirection) {
|
||||
|
@ -97,6 +97,16 @@ export class AppService {
|
||||
this.hostApp.setTitle(title)
|
||||
}
|
||||
})
|
||||
|
||||
tab.destroyed$.subscribe(() => {
|
||||
let newIndex = Math.max(0, this.tabs.indexOf(tab) - 1)
|
||||
this.tabs = this.tabs.filter((x) => x !== tab)
|
||||
if (tab === this.activeTab) {
|
||||
this.selectTab(this.tabs[newIndex])
|
||||
}
|
||||
this.tabsChanged.next()
|
||||
this.tabClosed.next(tab)
|
||||
})
|
||||
}
|
||||
|
||||
openNewTabRaw (type: TabComponentType, inputs?: any): BaseTabComponent {
|
||||
@ -177,14 +187,7 @@ export class AppService {
|
||||
if (checkCanClose && !await tab.canClose()) {
|
||||
return
|
||||
}
|
||||
let newIndex = Math.max(0, this.tabs.indexOf(tab) - 1)
|
||||
this.tabs = this.tabs.filter((x) => x !== tab)
|
||||
tab.destroy()
|
||||
if (tab === this.activeTab) {
|
||||
this.selectTab(this.tabs[newIndex])
|
||||
}
|
||||
this.tabsChanged.next()
|
||||
this.tabClosed.next(tab)
|
||||
}
|
||||
|
||||
async duplicateTab (tab: BaseTabComponent) {
|
||||
|
@ -370,7 +370,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
|
||||
this.sessionCloseSubscription = this.session.closed$.subscribe(() => {
|
||||
this.frontend.destroy()
|
||||
this.app.closeTab(this)
|
||||
this.destroy()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user