@@ -294,7 +294,7 @@ function getHelpSubmenu(): MenuItemConstructorOptions[] {
294294
295295function getWindowSubmenu (
296296 tabs : TabData [ ] ,
297- activeTabIndex ?: number ,
297+ activeTabId ?: string ,
298298) : MenuItemConstructorOptions [ ] {
299299 const initialSubmenu : MenuItemConstructorOptions [ ] = [
300300 {
@@ -326,7 +326,7 @@ function getWindowSubmenu(
326326 label : tab . label ,
327327 accelerator :
328328 tab . role === "function" ? "" : `${ shortcutKey } + ${ tab . index + 1 } ` ,
329- checked : tab . index === activeTabIndex ,
329+ checked : tab . id === activeTabId ,
330330 click ( _item , focusedWindow ) {
331331 if ( focusedWindow ) {
332332 sendAction ( "switch-server-tab" , tab . id ) ;
@@ -346,10 +346,7 @@ function getWindowSubmenu(
346346 enabled : tabs . length > 1 ,
347347 click ( _item , focusedWindow ) {
348348 if ( focusedWindow ) {
349- sendAction (
350- "switch-server-tab" ,
351- getNextServer ( tabs , activeTabIndex ! ) ,
352- ) ;
349+ sendAction ( "switch-server-tab" , getNextServer ( tabs , activeTabId ! ) ) ;
353350 }
354351 } ,
355352 } ,
@@ -361,7 +358,7 @@ function getWindowSubmenu(
361358 if ( focusedWindow ) {
362359 sendAction (
363360 "switch-server-tab" ,
364- getPreviousServer ( tabs , activeTabIndex ! ) ,
361+ getPreviousServer ( tabs , activeTabId ! ) ,
365362 ) ;
366363 }
367364 } ,
@@ -375,7 +372,7 @@ function getWindowSubmenu(
375372function getDarwinTpl (
376373 properties : MenuProperties ,
377374) : MenuItemConstructorOptions [ ] {
378- const { tabs, activeTabIndex , enableMenu = false } = properties ;
375+ const { tabs, activeTabId , enableMenu = false } = properties ;
379376
380377 return [
381378 {
@@ -525,7 +522,7 @@ function getDarwinTpl(
525522 } ,
526523 {
527524 label : t . __ ( "Window" ) ,
528- submenu : getWindowSubmenu ( tabs , activeTabIndex ) ,
525+ submenu : getWindowSubmenu ( tabs , activeTabId ) ,
529526 } ,
530527 {
531528 label : t . __ ( "Tools" ) ,
@@ -540,7 +537,7 @@ function getDarwinTpl(
540537}
541538
542539function getOtherTpl ( properties : MenuProperties ) : MenuItemConstructorOptions [ ] {
543- const { tabs, activeTabIndex , enableMenu = false } = properties ;
540+ const { tabs, activeTabId , enableMenu = false } = properties ;
544541 return [
545542 {
546543 label : t . __ ( "File" ) ,
@@ -673,7 +670,7 @@ function getOtherTpl(properties: MenuProperties): MenuItemConstructorOptions[] {
673670 } ,
674671 {
675672 label : t . __ ( "Window" ) ,
676- submenu : getWindowSubmenu ( tabs , activeTabIndex ) ,
673+ submenu : getWindowSubmenu ( tabs , activeTabId ) ,
677674 } ,
678675 {
679676 label : t . __ ( "Tools" ) ,
@@ -704,7 +701,8 @@ async function checkForUpdate(): Promise<void> {
704701 await appUpdater ( true ) ;
705702}
706703
707- function getNextServer ( tabs : TabData [ ] , activeTab : TabData ) : string {
704+ function getNextServer ( tabs : TabData [ ] , activeTabId : string ) : string {
705+ const activeTab = tabs . find ( ( tab ) => tab . id === activeTabId ) ! ;
708706 let { index} = activeTab ;
709707 do {
710708 index = ( index + 1 ) % tabs . length ;
@@ -713,7 +711,8 @@ function getNextServer(tabs: TabData[], activeTab: TabData): string {
713711 return tabs [ index ] . id ;
714712}
715713
716- function getPreviousServer ( tabs : TabData [ ] , activeTab : TabData ) : string {
714+ function getPreviousServer ( tabs : TabData [ ] , activeTabId : string ) : string {
715+ const activeTab = tabs . find ( ( tab ) => tab . id === activeTabId ) ! ;
717716 let { index} = activeTab ;
718717 do {
719718 index = ( index - 1 + tabs . length ) % tabs . length ;
0 commit comments