@@ -232,6 +232,10 @@ impl Status {
232232 }
233233 }
234234
235+ fn is_focus_on_diff ( & self ) -> bool {
236+ self . focus == Focus :: Diff
237+ }
238+
235239 fn switch_focus ( & mut self , f : Focus ) -> Result < bool > {
236240 if self . focus != f {
237241 self . focus = f;
@@ -455,6 +459,8 @@ impl Component for Status {
455459 out : & mut Vec < CommandInfo > ,
456460 force_all : bool ,
457461 ) -> CommandBlocking {
462+ let focus_on_diff = self . is_focus_on_diff ( ) ;
463+
458464 if self . visible || force_all {
459465 command_pump (
460466 out,
@@ -467,30 +473,29 @@ impl Component for Status {
467473 & self . key_config ,
468474 ) ,
469475 true ,
470- true ,
476+ !focus_on_diff ,
471477 ) ) ;
472478
473479 out. push ( CommandInfo :: new (
474480 strings:: commands:: status_push ( & self . key_config ) ,
475481 self . can_push ( ) ,
476- true ,
482+ !focus_on_diff ,
477483 ) ) ;
478484 out. push ( CommandInfo :: new (
479485 strings:: commands:: status_force_push (
480486 & self . key_config ,
481487 ) ,
482- self . can_push ( ) ,
483488 true ,
489+ self . can_push ( ) && !focus_on_diff,
484490 ) ) ;
485491 out. push ( CommandInfo :: new (
486492 strings:: commands:: status_pull ( & self . key_config ) ,
487493 true ,
488- true ,
494+ !focus_on_diff ,
489495 ) ) ;
490496 }
491497
492498 {
493- let focus_on_diff = self . focus == Focus :: Diff ;
494499 out. push ( CommandInfo :: new (
495500 strings:: commands:: edit_item ( & self . key_config ) ,
496501 if focus_on_diff {
@@ -510,17 +515,18 @@ impl Component for Status {
510515 self . can_focus_diff ( ) ,
511516 ( self . visible && !focus_on_diff) || force_all,
512517 ) ) ;
513- }
514518
515- out. push (
516- CommandInfo :: new (
517- strings:: commands:: select_status ( & self . key_config ) ,
518- true ,
519- ( self . visible && self . focus == Focus :: Diff )
520- || force_all,
521- )
522- . hidden ( ) ,
523- ) ;
519+ out. push (
520+ CommandInfo :: new (
521+ strings:: commands:: select_status (
522+ & self . key_config ,
523+ ) ,
524+ true ,
525+ ( self . visible && !focus_on_diff) || force_all,
526+ )
527+ . hidden ( ) ,
528+ ) ;
529+ }
524530
525531 visibility_blocking ( self )
526532 }
@@ -535,7 +541,7 @@ impl Component for Status {
535541 if let Event :: Key ( k) = ev {
536542 return if k == self . key_config . edit_file
537543 && ( self . can_focus_diff ( )
538- || self . focus == Focus :: Diff )
544+ || self . is_focus_on_diff ( ) )
539545 {
540546 if let Some ( ( path, _) ) = self . selected_path ( ) {
541547 self . queue . borrow_mut ( ) . push_back (
@@ -564,18 +570,27 @@ impl Component for Status {
564570 && !self . index_wd . is_empty ( )
565571 {
566572 self . switch_focus ( Focus :: WorkDir )
567- } else if k == self . key_config . select_branch {
573+ } else if k == self . key_config . select_branch
574+ && !self . is_focus_on_diff ( )
575+ {
568576 self . queue
569577 . borrow_mut ( )
570578 . push_back ( InternalEvent :: SelectBranch ) ;
571579 Ok ( true )
572- } else if k == self . key_config . force_push {
580+ } else if k == self . key_config . force_push
581+ && !self . is_focus_on_diff ( )
582+ && self . can_push ( )
583+ {
573584 self . push ( true ) ;
574585 Ok ( true )
575- } else if k == self . key_config . push {
586+ } else if k == self . key_config . push
587+ && !self . is_focus_on_diff ( )
588+ {
576589 self . push ( false ) ;
577590 Ok ( true )
578- } else if k == self . key_config . pull {
591+ } else if k == self . key_config . pull
592+ && !self . is_focus_on_diff ( )
593+ {
579594 self . pull ( ) ;
580595 Ok ( true )
581596 } else {
0 commit comments