@@ -505,30 +505,41 @@ impl ConventionalCommitPopup {
505505
506506 pub fn quick_shortcuts ( & self ) -> Vec < char > {
507507 // Missing `i`, because `i` is mapped to insert sorry~
508- let default = "qwertyuopasdfghjklmzxcvbn" ;
508+ let mut available_chars =
509+ ( 'a' ..='z' ) . into_iter ( ) . collect_vec ( ) ;
509510
510- let dont_map_keys = [
511+ [
511512 self . key_config . keys . move_down ,
512513 self . key_config . keys . move_up ,
513514 self . key_config . keys . exit_popup ,
514515 self . key_config . keys . exit ,
515516 self . key_config . keys . insert ,
516517 ]
517518 . into_iter ( )
518- . filter_map ( |k| {
519+ . for_each ( |k| {
519520 if let KeyCode :: Char ( c) = k. code {
520- Some ( c)
521- } else {
522- None
521+ if let Some ( char_to_remove_index) =
522+ available_chars. iter ( ) . position ( |& ch| ch == c)
523+ {
524+ available_chars. remove ( char_to_remove_index) ;
525+ }
523526 }
524- } )
525- . collect_vec ( ) ;
526-
527- default
528- . chars ( )
529- . filter ( |c| !dont_map_keys. contains ( c) )
530- . take ( self . query_results . len ( ) )
531- . collect_vec ( )
527+ } ) ;
528+
529+ self . query_results
530+ . iter ( )
531+ . map ( |commit_type| commit_type. to_string ( ) )
532+ . map ( |s| {
533+ if let Some ( ch) = s. chars ( )
534+ . into_iter ( )
535+ . find ( |c| available_chars. contains ( & c) ) {
536+ available_chars. retain ( |& c| c != ch) ;
537+ ch
538+ } else {
539+ * available_chars. first ( ) . expect ( "Should already have at least one letter available" )
540+ }
541+ } )
542+ . collect_vec ( )
532543 }
533544
534545 pub fn move_selection ( & mut self , direction : ScrollType ) {
@@ -682,6 +693,7 @@ impl Component for ConventionalCommitPopup {
682693 if self . is_insert {
683694 println ! ( "lol" ) ;
684695 }
696+
685697 if let Event :: Key ( key) = event {
686698 if key_match ( key, self . key_config . keys . exit_popup )
687699 || key_match ( key, self . key_config . keys . enter )
0 commit comments