Skip to content

Commit

Permalink
fix: tabs: move: additional dst checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mbnuqw committed Feb 2, 2025
1 parent 9635915 commit bfd8b39
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/services/tabs.fg.move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ export async function move(
if (dst.windowId === NOID) return
}

// Check if target panel exists
if (dst.panelId) {
const dstPanel = Sidebar.panelsById[dst.panelId]
if (!Utils.isTabsPanel(dstPanel)) {
Logs.warn('Tabs.move: wrong type of target panel:', Utils.clone(dstPanel))
return
}
}

// Move tabs from another window to this window
if (src.windowId !== undefined && src.windowId !== Windows.id) {
const tabIds = tabsInfo.map(t => t.id)
Expand Down Expand Up @@ -86,7 +95,7 @@ export async function move(
}

// Gather tabs by type (pinned/normal), get initial info
const dstTab: Tab | undefined = Tabs.list[dst.index]
const dstTab = Tabs.list[dst.index] as Tab | undefined
const dstParent = Tabs.byId[dst.parentId]
const pinnedTabs: Tab[] = []
const normalTabs: Tab[] = []
Expand All @@ -103,6 +112,7 @@ export async function move(
tabs.push(tab)
}

if (dstTab?.pinned && !dst.pinned) return
if (!tabs.length) return

// Switch panelId of pinned tabs and exclude them from general list
Expand Down

0 comments on commit bfd8b39

Please sign in to comment.