diff --git a/app/src/menus/tab.ts b/app/src/menus/tab.ts index 29ce0ddc0..639bafec7 100644 --- a/app/src/menus/tab.ts +++ b/app/src/menus/tab.ts @@ -131,13 +131,23 @@ const splitSubMenu = (app: App, tab: Tab) => { } }); } - const wndsTemp: Wnd[] = []; - getAllWnds(window.siyuan.layout.layout, wndsTemp); + let wndsTemp: Wnd[] = []; + getAllWnds(window.siyuan.layout.centerLayout, wndsTemp); if (wndsTemp.length > 1) { subMenus.push({ label: window.siyuan.languages.unsplit, click: () => { - unsplitWnd(tab.parent.parent.children[0], tab.parent.parent, true); + let layout = tab.parent.parent; + while (layout.id !== window.siyuan.layout.centerLayout.id) { + wndsTemp = []; + getAllWnds(layout, wndsTemp); + if (wndsTemp.length > 1) { + break; + } else { + layout = layout.parent; + } + } + unsplitWnd(tab.parent.parent.children[0], layout, true); resizeTabs(); } });