@@ -561,6 +561,20 @@ impl ConventionalCommitPopup {
561
561
. cloned ( )
562
562
. collect_vec ( ) ;
563
563
}
564
+
565
+ fn validate_escape ( & mut self , commit_type : CommitType ) {
566
+ let ( emoji, short_msg, _) =
567
+ commit_type. more_info ( ) [ self . selected_index ] . strings ( ) ;
568
+ self . queue . push ( crate :: queue:: InternalEvent :: OpenCommit ) ;
569
+ self . queue . push (
570
+ crate :: queue:: InternalEvent :: AddCommitMessage ( format ! (
571
+ "{emoji} {commit_type}: {short_msg}"
572
+ ) ) ,
573
+ ) ;
574
+ self . hide ( ) ;
575
+ self . selected_index = 0 ;
576
+ self . seleted_commit_type = None ;
577
+ }
564
578
}
565
579
566
580
impl DrawableComponent for ConventionalCommitPopup {
@@ -649,7 +663,6 @@ impl Component for ConventionalCommitPopup {
649
663
650
664
visibility_blocking ( self )
651
665
}
652
-
653
666
fn event (
654
667
& mut self ,
655
668
event : & crossterm:: event:: Event ,
@@ -663,27 +676,25 @@ impl Component for ConventionalCommitPopup {
663
676
|| key_match ( key, self . key_config . keys . enter )
664
677
{
665
678
if let Some ( commit_type) =
666
- & self . seleted_commit_type
679
+ self . seleted_commit_type . clone ( )
667
680
{
668
- let ( emoji, short_msg, _) = commit_type. more_info ( ) [ self . selected_index ] . strings ( ) ;
669
- self . queue . push (
670
- crate :: queue:: InternalEvent :: OpenCommit ,
671
- ) ;
672
- self . queue . push (
673
- crate :: queue:: InternalEvent :: AddCommitMessage (
674
-
675
- format ! ( "{emoji} {commit_type}: {short_msg}" ) ,
676
- ) ,
677
- ) ;
678
- self . hide ( ) ;
679
- self . selected_index = 0 ;
680
- self . seleted_commit_type = None ;
681
+ self . validate_escape ( commit_type) ;
681
682
} else {
682
- self . seleted_commit_type = self
683
+ let commit = self
683
684
. query_results
684
685
. get ( self . selected_index )
685
686
. cloned ( ) ;
687
+
688
+ self . seleted_commit_type = commit. clone ( ) ;
686
689
self . selected_index = 0 ;
690
+
691
+ if let Some ( more_infos) =
692
+ commit. as_ref ( ) . map ( |c| c. more_info ( ) )
693
+ {
694
+ if more_infos. len ( ) == 1 {
695
+ self . validate_escape ( commit. unwrap ( ) ) ;
696
+ }
697
+ }
687
698
}
688
699
} else if key_match ( key, self . key_config . keys . insert )
689
700
{
0 commit comments