File tree Expand file tree Collapse file tree 2 files changed +28
-10
lines changed Expand file tree Collapse file tree 2 files changed +28
-10
lines changed Original file line number Diff line number Diff line change @@ -520,6 +520,7 @@ where
520520 }
521521 if matches ! ( self . selected, Some ( 0 ) ) && !super :: GLOBAL_ACTIONS . is_empty ( ) {
522522 self . focus = Focus :: GlobalActions ;
523+ self . global_action_selected = super :: GLOBAL_ACTIONS . len ( ) . saturating_sub ( 1 ) ;
523524 return ;
524525 }
525526 let next = match self . selected {
@@ -531,15 +532,7 @@ where
531532 }
532533 Focus :: Actions => self . move_action ( -1 ) ,
533534 Focus :: GlobalActions => {
534- if self . global_action_selected == 0 {
535- if !self . worktrees . is_empty ( ) {
536- self . focus = Focus :: Worktrees ;
537- if self . selected . is_none ( ) {
538- self . selected = Some ( 0 ) ;
539- }
540- self . sync_selection ( state) ;
541- }
542- } else {
535+ if self . global_action_selected > 0 {
543536 self . move_global_action ( -1 ) ;
544537 }
545538 }
Original file line number Diff line number Diff line change @@ -302,11 +302,36 @@ fn cd_to_root_global_action_exits() -> Result<()> {
302302
303303#[ test]
304304fn up_from_top_moves_to_global_actions ( ) -> Result < ( ) > {
305+ let backend = TestBackend :: new ( 40 , 12 ) ;
306+ let terminal = Terminal :: new ( backend) ?;
307+ let events = StubEvents :: new ( vec ! [ key( KeyCode :: Up ) , key( KeyCode :: Enter ) ] ) ;
308+
309+ let worktrees = entries ( & [ "alpha" ] ) ;
310+ let command = InteractiveCommand :: new (
311+ terminal,
312+ events,
313+ PathBuf :: from ( "/tmp/worktrees" ) ,
314+ worktrees,
315+ vec ! [ String :: from( "main" ) ] ,
316+ Some ( String :: from ( "main" ) ) ,
317+ ) ;
318+
319+ let result = command. run ( |_| Ok ( ( ) ) , |_, _| Ok ( ( ) ) ) ?;
320+
321+ assert_eq ! ( result, Some ( String :: from( super :: REPO_ROOT_SELECTION ) ) ) ;
322+
323+ Ok ( ( ) )
324+ }
325+
326+ #[ test]
327+ fn up_from_top_after_tabbing_picks_last_global_action ( ) -> Result < ( ) > {
305328 let backend = TestBackend :: new ( 40 , 12 ) ;
306329 let terminal = Terminal :: new ( backend) ?;
307330 let events = StubEvents :: new ( vec ! [
331+ key( KeyCode :: Tab ) ,
332+ key( KeyCode :: Tab ) ,
333+ key( KeyCode :: Tab ) ,
308334 key( KeyCode :: Up ) ,
309- key( KeyCode :: Right ) ,
310335 key( KeyCode :: Enter ) ,
311336 ] ) ;
312337
You can’t perform that action at this time.
0 commit comments