@@ -692,6 +692,7 @@ pub(crate) struct Screen {
692
692
connected_clients : Rc < RefCell < HashSet < ClientId > > > ,
693
693
/// The indices of this [`Screen`]'s active [`Tab`]s.
694
694
active_tab_indices : BTreeMap < ClientId , usize > ,
695
+ global_last_active_tab_index : usize ,
695
696
tab_history : BTreeMap < ClientId , Vec < usize > > ,
696
697
mode_info : BTreeMap < ClientId , ModeInfo > ,
697
698
default_mode_info : ModeInfo , // TODO: restructure ModeInfo to prevent this duplication
@@ -764,6 +765,7 @@ impl Screen {
764
765
style : client_attributes. style ,
765
766
connected_clients : Rc :: new ( RefCell :: new ( HashSet :: new ( ) ) ) ,
766
767
active_tab_indices : BTreeMap :: new ( ) ,
768
+ global_last_active_tab_index : 0 ,
767
769
tabs : BTreeMap :: new ( ) ,
768
770
overlay : OverlayWindow :: default ( ) ,
769
771
terminal_emulator_colors : Rc :: new ( RefCell :: new ( Palette :: default ( ) ) ) ,
@@ -1523,6 +1525,8 @@ impl Screen {
1523
1525
self . active_tab_indices . iter ( ) . next ( )
1524
1526
{
1525
1527
* first_active_tab_index
1528
+ } else if self . tabs . contains_key ( & self . global_last_active_tab_index ) {
1529
+ self . global_last_active_tab_index
1526
1530
} else if self . tabs . contains_key ( & 0 ) {
1527
1531
0
1528
1532
} else if let Some ( tab_index) = self . tabs . keys ( ) . next ( ) {
@@ -1551,6 +1555,7 @@ impl Screen {
1551
1555
}
1552
1556
}
1553
1557
if self . active_tab_indices . contains_key ( & client_id) {
1558
+ self . global_last_active_tab_index = * self . active_tab_indices . get ( & client_id) . unwrap ( ) ;
1554
1559
self . active_tab_indices . remove ( & client_id) ;
1555
1560
}
1556
1561
if self . tab_history . contains_key ( & client_id) {
0 commit comments