@@ -50,6 +50,7 @@ enum CommitType {
50
50
CI ,
51
51
}
52
52
53
+ #[ cfg( feature = "gitmoji" ) ]
53
54
#[ derive( Copy , Clone ) ]
54
55
enum MoreInfoCommit {
55
56
/// 🎨
@@ -150,6 +151,7 @@ enum MoreInfoCommit {
150
151
Validation ,
151
152
}
152
153
154
+ #[ cfg( feature = "gitmoji" ) ]
153
155
impl MoreInfoCommit {
154
156
const fn strings (
155
157
self ,
@@ -237,6 +239,7 @@ impl MoreInfoCommit {
237
239
}
238
240
}
239
241
242
+ #[ cfg( feature = "gitmoji" ) ]
240
243
impl CommitType {
241
244
#[ allow( clippy:: pedantic) ]
242
245
fn more_info ( & self ) -> Vec < MoreInfoCommit > {
@@ -358,6 +361,7 @@ pub struct ConventionalCommitPopup {
358
361
selected_index : usize ,
359
362
options : Vec < CommitType > ,
360
363
query_results_type : Vec < CommitType > ,
364
+ #[ cfg( feature = "gitmoji" ) ]
361
365
query_results_more_info : Vec < MoreInfoCommit > ,
362
366
input : TextInputComponent ,
363
367
theme : SharedTheme ,
@@ -377,6 +381,7 @@ impl ConventionalCommitPopup {
377
381
input,
378
382
options : CommitType :: iter ( ) . collect_vec ( ) ,
379
383
query_results_type : CommitType :: iter ( ) . collect_vec ( ) ,
384
+ #[ cfg( feature = "gitmoji" ) ]
380
385
query_results_more_info : Vec :: new ( ) ,
381
386
is_insert : false ,
382
387
is_breaking : false ,
@@ -396,30 +401,48 @@ impl ConventionalCommitPopup {
396
401
397
402
let quick_shortcuts = self . quick_shortcuts ( ) ;
398
403
399
- let title = format ! (
400
- "Results: {}" ,
401
- if self . seleted_commit_type. is_some( ) {
402
- self . query_results_more_info. len( )
403
- } else {
404
+ let results = {
405
+ #[ cfg( feature = "gitmoji" ) ]
406
+ {
407
+ if self . seleted_commit_type . is_some ( ) {
408
+ self . query_results_more_info . len ( )
409
+ } else {
410
+ self . query_results_type . len ( )
411
+ }
412
+ }
413
+ #[ cfg( not( feature = "gitmoji" ) ) ]
414
+ {
404
415
self . query_results_type . len ( )
405
416
}
406
- ) ;
417
+ } ;
418
+
419
+ let title = format ! ( "Results: {results}" , ) ;
407
420
408
421
let iter_over = if self . seleted_commit_type . is_some ( ) {
409
- self . query_results_more_info
410
- . iter ( )
411
- . enumerate ( )
412
- . take ( height)
413
- . map ( |( idx, more_info) | {
414
- let ( emoji, _, long_name) = more_info. strings ( ) ;
415
- let text_string = format ! ( "{emoji} {long_name}" ) ;
416
- let text = trim_length_left ( & text_string, width) ;
417
- (
418
- self . selected_index == idx,
419
- format ! ( "{text}{:width$}" , " " ) ,
420
- )
421
- } )
422
- . collect_vec ( )
422
+ #[ cfg( feature = "gitmoji" ) ]
423
+ {
424
+ self . query_results_more_info
425
+ . iter ( )
426
+ . enumerate ( )
427
+ . take ( height)
428
+ . map ( |( idx, more_info) | {
429
+ let ( emoji, _, long_name) =
430
+ more_info. strings ( ) ;
431
+ let text_string =
432
+ format ! ( "{emoji} {long_name}" ) ;
433
+ let text =
434
+ trim_length_left ( & text_string, width) ;
435
+ (
436
+ self . selected_index == idx,
437
+ format ! ( "{text}{:width$}" , " " ) ,
438
+ )
439
+ } )
440
+ . collect_vec ( )
441
+ }
442
+ #[ cfg( not( feature = "gitmoji" ) ) ]
443
+ {
444
+ vec ! [ ]
445
+ }
423
446
} else {
424
447
let max_len = self
425
448
. query_results_type
@@ -516,7 +539,14 @@ impl ConventionalCommitPopup {
516
539
let new_selection = new_selection. clamp (
517
540
0 ,
518
541
if self . seleted_commit_type . is_some ( ) {
519
- self . query_results_more_info . len ( )
542
+ #[ cfg( feature = "gitmoji" ) ]
543
+ {
544
+ self . query_results_more_info . len ( )
545
+ }
546
+ #[ cfg( not( feature = "gitmoji" ) ) ]
547
+ {
548
+ self . query_results_type . len ( )
549
+ }
520
550
} else {
521
551
self . query_results_type . len ( )
522
552
}
@@ -544,20 +574,29 @@ impl ConventionalCommitPopup {
544
574
let new_len = if let Some ( commit_type) =
545
575
& self . seleted_commit_type
546
576
{
547
- self . query_results_more_info = commit_type
548
- . more_info ( )
549
- . iter ( )
550
- . filter ( |more_info_commit| {
551
- more_info_commit
552
- . strings ( )
553
- . 2
554
- . to_lowercase ( )
555
- . contains ( & query)
556
- } )
557
- . copied ( )
558
- . collect_vec ( ) ;
577
+ #[ cfg( feature = "gitmoji" ) ]
578
+ {
579
+ self . query_results_more_info = commit_type
580
+ . more_info ( )
581
+ . iter ( )
582
+ . filter ( |more_info_commit| {
583
+ more_info_commit
584
+ . strings ( )
585
+ . 2
586
+ . to_lowercase ( )
587
+ . contains ( & query)
588
+ } )
589
+ . copied ( )
590
+ . collect_vec ( ) ;
559
591
560
- self . query_results_more_info . len ( )
592
+ self . query_results_more_info . len ( )
593
+ }
594
+ #[ cfg( not( feature = "gitmoji" ) ) ]
595
+ {
596
+ let _ = commit_type;
597
+ self . hide ( ) ;
598
+ self . query_results_type . len ( )
599
+ }
561
600
} else {
562
601
self . query_results_type = self
563
602
. options
@@ -641,9 +680,14 @@ impl DrawableComponent for ConventionalCommitPopup {
641
680
. borders ( Borders :: all ( ) )
642
681
. style ( self . theme . title ( true ) )
643
682
. title ( Span :: styled (
644
- if self . seleted_commit_type . is_some ( ) {
645
- strings:: POPUP_TITLE_GITMOJI
646
- } else {
683
+ {
684
+ #[ cfg( feature = "gitmoji" ) ]
685
+ if self . seleted_commit_type . is_some ( ) {
686
+ strings:: POPUP_TITLE_GITMOJI
687
+ } else {
688
+ strings:: POPUP_TITLE_CONVENTIONAL_COMMIT
689
+ }
690
+ #[ cfg( not( feature = "gitmoji" ) ) ]
647
691
strings:: POPUP_TITLE_CONVENTIONAL_COMMIT
648
692
} ,
649
693
self . theme . title ( true ) ,
@@ -835,7 +879,10 @@ impl Component for ConventionalCommitPopup {
835
879
self . is_visible = false ;
836
880
self . seleted_commit_type = None ;
837
881
self . query_results_type = CommitType :: iter ( ) . collect_vec ( ) ;
838
- self . query_results_more_info = Vec :: new ( ) ;
882
+ #[ cfg( feature = "gitmoji" ) ]
883
+ {
884
+ self . query_results_more_info . clear ( ) ;
885
+ }
839
886
}
840
887
841
888
fn show ( & mut self ) -> Result < ( ) > {
0 commit comments