Skip to content

Commit b6729b0

Browse files
committed
menu: Skip missing elements of tabs array.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent ec7d5b4 commit b6729b0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/main/menu.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,10 @@ function getWindowSubmenu(
312312
type: "separator",
313313
});
314314
for (const tab of tabs) {
315+
// Skip missing elements left by `delete this.tabs[index]` in
316+
// ServerManagerView.
317+
if (tab === undefined) continue;
318+
315319
// Do not add functional tab settings to list of windows in menu bar
316320
if (tab.role === "function" && tab.name === "Settings") {
317321
continue;
@@ -700,15 +704,15 @@ async function checkForUpdate(): Promise<void> {
700704
function getNextServer(tabs: TabData[], activeTabIndex: number): number {
701705
do {
702706
activeTabIndex = (activeTabIndex + 1) % tabs.length;
703-
} while (tabs[activeTabIndex].role !== "server");
707+
} while (tabs[activeTabIndex]?.role !== "server");
704708

705709
return activeTabIndex;
706710
}
707711

708712
function getPreviousServer(tabs: TabData[], activeTabIndex: number): number {
709713
do {
710714
activeTabIndex = (activeTabIndex - 1 + tabs.length) % tabs.length;
711-
} while (tabs[activeTabIndex].role !== "server");
715+
} while (tabs[activeTabIndex]?.role !== "server");
712716

713717
return activeTabIndex;
714718
}

0 commit comments

Comments
 (0)