@@ -394,20 +394,27 @@ impl Component for StatusTreeComponent {
394
394
out : & mut Vec < CommandInfo > ,
395
395
force_all : bool ,
396
396
) -> CommandBlocking {
397
+ let available = self . focused || force_all;
398
+ let selection = self . selection_file ( ) ;
399
+ let selected_is_file = selection. is_some ( ) ;
400
+ let tracked = selection. is_some_and ( |s| {
401
+ !matches ! ( s. status, StatusItemType :: New )
402
+ } ) ;
403
+
397
404
out. push (
398
405
CommandInfo :: new (
399
406
strings:: commands:: navigate_tree ( & self . key_config ) ,
400
407
!self . is_empty ( ) ,
401
- self . focused || force_all ,
408
+ available ,
402
409
)
403
410
. order ( order:: NAV ) ,
404
411
) ;
405
412
406
413
out. push (
407
414
CommandInfo :: new (
408
415
strings:: commands:: blame_file ( & self . key_config ) ,
409
- self . selection_file ( ) . is_some ( ) ,
410
- self . focused || force_all ,
416
+ selected_is_file && tracked ,
417
+ available ,
411
418
)
412
419
. order ( order:: RARE_ACTION ) ,
413
420
) ;
@@ -417,26 +424,26 @@ impl Component for StatusTreeComponent {
417
424
strings:: commands:: open_file_history (
418
425
& self . key_config ,
419
426
) ,
420
- self . selection_file ( ) . is_some ( ) ,
421
- self . focused || force_all ,
427
+ selected_is_file && tracked ,
428
+ available ,
422
429
)
423
430
. order ( order:: RARE_ACTION ) ,
424
431
) ;
425
432
426
433
out. push (
427
434
CommandInfo :: new (
428
435
strings:: commands:: edit_item ( & self . key_config ) ,
429
- self . selection_file ( ) . is_some ( ) ,
430
- self . focused || force_all ,
436
+ selected_is_file ,
437
+ available ,
431
438
)
432
439
. order ( order:: RARE_ACTION ) ,
433
440
) ;
434
441
435
442
out. push (
436
443
CommandInfo :: new (
437
444
strings:: commands:: copy_path ( & self . key_config ) ,
438
- self . selection_file ( ) . is_some ( ) ,
439
- self . focused || force_all ,
445
+ selected_is_file ,
446
+ available ,
440
447
)
441
448
. order ( order:: RARE_ACTION ) ,
442
449
) ;
@@ -448,30 +455,53 @@ impl Component for StatusTreeComponent {
448
455
if self . focused {
449
456
if let Event :: Key ( e) = ev {
450
457
return if key_match ( e, self . key_config . keys . blame ) {
451
- if let Some ( status_item) = self . selection_file ( ) {
452
- self . hide ( ) ;
453
- self . queue . push ( InternalEvent :: OpenPopup (
454
- StackablePopupOpen :: BlameFile (
455
- BlameFileOpen {
456
- file_path : status_item. path ,
457
- commit_id : self . revision ,
458
- selection : None ,
459
- } ,
460
- ) ,
461
- ) ) ;
458
+ match self . selection_file ( ) {
459
+ Some ( status_item)
460
+ if !matches ! (
461
+ status_item. status,
462
+ StatusItemType :: New
463
+ ) =>
464
+ {
465
+ self . hide ( ) ;
466
+ self . queue . push (
467
+ InternalEvent :: OpenPopup (
468
+ StackablePopupOpen :: BlameFile (
469
+ BlameFileOpen {
470
+ file_path : status_item
471
+ . path ,
472
+ commit_id : self . revision ,
473
+ selection : None ,
474
+ } ,
475
+ ) ,
476
+ ) ,
477
+ ) ;
478
+ }
479
+ _ => { }
462
480
}
463
481
Ok ( EventState :: Consumed )
464
482
} else if key_match (
465
483
e,
466
484
self . key_config . keys . file_history ,
467
485
) {
468
- if let Some ( status_item) = self . selection_file ( ) {
469
- self . hide ( ) ;
470
- self . queue . push ( InternalEvent :: OpenPopup (
471
- StackablePopupOpen :: FileRevlog (
472
- FileRevOpen :: new ( status_item. path ) ,
473
- ) ,
474
- ) ) ;
486
+ match self . selection_file ( ) {
487
+ Some ( status_item)
488
+ if !matches ! (
489
+ status_item. status,
490
+ StatusItemType :: New
491
+ ) =>
492
+ {
493
+ self . hide ( ) ;
494
+ self . queue . push (
495
+ InternalEvent :: OpenPopup (
496
+ StackablePopupOpen :: FileRevlog (
497
+ FileRevOpen :: new (
498
+ status_item. path ,
499
+ ) ,
500
+ ) ,
501
+ ) ,
502
+ ) ;
503
+ }
504
+ _ => { }
475
505
}
476
506
Ok ( EventState :: Consumed )
477
507
} else if key_match ( e, self . key_config . keys . edit_file )
0 commit comments