提交 d25751ab 编写于 作者: E Eugene Pankov

handle split pane being closed

上级 bcc4a262
......@@ -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()
})
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册