@@ -561,6 +561,20 @@ impl ConventionalCommitPopup {
561561 . cloned ( )
562562 . collect_vec ( ) ;
563563 }
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+ }
564578}
565579
566580impl DrawableComponent for ConventionalCommitPopup {
@@ -649,7 +663,6 @@ impl Component for ConventionalCommitPopup {
649663
650664 visibility_blocking ( self )
651665 }
652-
653666 fn event (
654667 & mut self ,
655668 event : & crossterm:: event:: Event ,
@@ -663,27 +676,25 @@ impl Component for ConventionalCommitPopup {
663676 || key_match ( key, self . key_config . keys . enter )
664677 {
665678 if let Some ( commit_type) =
666- & self . seleted_commit_type
679+ self . seleted_commit_type . clone ( )
667680 {
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) ;
681682 } else {
682- self . seleted_commit_type = self
683+ let commit = self
683684 . query_results
684685 . get ( self . selected_index )
685686 . cloned ( ) ;
687+
688+ self . seleted_commit_type = commit. clone ( ) ;
686689 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+ }
687698 }
688699 } else if key_match ( key, self . key_config . keys . insert )
689700 {
0 commit comments