@@ -232,6 +232,10 @@ impl Status {
232
232
}
233
233
}
234
234
235
+ fn is_focus_on_diff ( & self ) -> bool {
236
+ self . focus == Focus :: Diff
237
+ }
238
+
235
239
fn switch_focus ( & mut self , f : Focus ) -> Result < bool > {
236
240
if self . focus != f {
237
241
self . focus = f;
@@ -455,6 +459,8 @@ impl Component for Status {
455
459
out : & mut Vec < CommandInfo > ,
456
460
force_all : bool ,
457
461
) -> CommandBlocking {
462
+ let focus_on_diff = self . is_focus_on_diff ( ) ;
463
+
458
464
if self . visible || force_all {
459
465
command_pump (
460
466
out,
@@ -467,30 +473,29 @@ impl Component for Status {
467
473
& self . key_config ,
468
474
) ,
469
475
true ,
470
- true ,
476
+ !focus_on_diff ,
471
477
) ) ;
472
478
473
479
out. push ( CommandInfo :: new (
474
480
strings:: commands:: status_push ( & self . key_config ) ,
475
481
self . can_push ( ) ,
476
- true ,
482
+ !focus_on_diff ,
477
483
) ) ;
478
484
out. push ( CommandInfo :: new (
479
485
strings:: commands:: status_force_push (
480
486
& self . key_config ,
481
487
) ,
482
- self . can_push ( ) ,
483
488
true ,
489
+ self . can_push ( ) && !focus_on_diff,
484
490
) ) ;
485
491
out. push ( CommandInfo :: new (
486
492
strings:: commands:: status_pull ( & self . key_config ) ,
487
493
true ,
488
- true ,
494
+ !focus_on_diff ,
489
495
) ) ;
490
496
}
491
497
492
498
{
493
- let focus_on_diff = self . focus == Focus :: Diff ;
494
499
out. push ( CommandInfo :: new (
495
500
strings:: commands:: edit_item ( & self . key_config ) ,
496
501
if focus_on_diff {
@@ -510,17 +515,18 @@ impl Component for Status {
510
515
self . can_focus_diff ( ) ,
511
516
( self . visible && !focus_on_diff) || force_all,
512
517
) ) ;
513
- }
514
518
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
+ }
524
530
525
531
visibility_blocking ( self )
526
532
}
@@ -535,7 +541,7 @@ impl Component for Status {
535
541
if let Event :: Key ( k) = ev {
536
542
return if k == self . key_config . edit_file
537
543
&& ( self . can_focus_diff ( )
538
- || self . focus == Focus :: Diff )
544
+ || self . is_focus_on_diff ( ) )
539
545
{
540
546
if let Some ( ( path, _) ) = self . selected_path ( ) {
541
547
self . queue . borrow_mut ( ) . push_back (
@@ -564,18 +570,27 @@ impl Component for Status {
564
570
&& !self . index_wd . is_empty ( )
565
571
{
566
572
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
+ {
568
576
self . queue
569
577
. borrow_mut ( )
570
578
. push_back ( InternalEvent :: SelectBranch ) ;
571
579
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
+ {
573
584
self . push ( true ) ;
574
585
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
+ {
576
589
self . push ( false ) ;
577
590
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
+ {
579
594
self . pull ( ) ;
580
595
Ok ( true )
581
596
} else {
0 commit comments