@@ -20,7 +20,8 @@ use crate::{
20
20
options:: { Options , SharedOptions } ,
21
21
popup_stack:: PopupStack ,
22
22
queue:: {
23
- Action , InternalEvent , NeedsUpdate , Queue , StackablePopupOpen ,
23
+ Action , AppTabs , InternalEvent , NeedsUpdate , Queue ,
24
+ StackablePopupOpen ,
24
25
} ,
25
26
setup_popups,
26
27
strings:: { self , ellipsis_trim_start, order} ,
@@ -697,15 +698,15 @@ impl App {
697
698
698
699
fn switch_tab ( & mut self , k : & KeyEvent ) -> Result < ( ) > {
699
700
if key_match ( k, self . key_config . keys . tab_status ) {
700
- self . set_tab ( 0 ) ?;
701
+ self . switch_to_tab ( & AppTabs :: Status ) ?;
701
702
} else if key_match ( k, self . key_config . keys . tab_log ) {
702
- self . set_tab ( 1 ) ?;
703
+ self . switch_to_tab ( & AppTabs :: Log ) ?;
703
704
} else if key_match ( k, self . key_config . keys . tab_files ) {
704
- self . set_tab ( 2 ) ?;
705
+ self . switch_to_tab ( & AppTabs :: Files ) ?;
705
706
} else if key_match ( k, self . key_config . keys . tab_stashing ) {
706
- self . set_tab ( 3 ) ?;
707
+ self . switch_to_tab ( & AppTabs :: Stashing ) ?;
707
708
} else if key_match ( k, self . key_config . keys . tab_stashes ) {
708
- self . set_tab ( 4 ) ?;
709
+ self . switch_to_tab ( & AppTabs :: Stashlist ) ?;
709
710
}
710
711
711
712
Ok ( ( ) )
@@ -727,6 +728,17 @@ impl App {
727
728
Ok ( ( ) )
728
729
}
729
730
731
+ fn switch_to_tab ( & mut self , tab : & AppTabs ) -> Result < ( ) > {
732
+ match tab {
733
+ AppTabs :: Status => self . set_tab ( 0 ) ?,
734
+ AppTabs :: Log => self . set_tab ( 1 ) ?,
735
+ AppTabs :: Files => self . set_tab ( 2 ) ?,
736
+ AppTabs :: Stashing => self . set_tab ( 3 ) ?,
737
+ AppTabs :: Stashlist => self . set_tab ( 4 ) ?,
738
+ }
739
+ Ok ( ( ) )
740
+ }
741
+
730
742
fn update_commands ( & mut self ) {
731
743
if self . help . is_visible ( ) {
732
744
self . help . set_cmds ( self . commands ( true ) ) ;
@@ -855,6 +867,10 @@ impl App {
855
867
self . tags_popup . open ( ) ?;
856
868
}
857
869
InternalEvent :: TabSwitchStatus => self . set_tab ( 0 ) ?,
870
+ InternalEvent :: TabSwitch ( tab) => {
871
+ self . switch_to_tab ( & tab) ?;
872
+ flags. insert ( NeedsUpdate :: ALL ) ;
873
+ }
858
874
InternalEvent :: SelectCommitInRevlog ( id) => {
859
875
if let Err ( error) = self . revlog . select_commit ( id) {
860
876
self . queue . push ( InternalEvent :: ShowErrorMsg (
0 commit comments