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