1
+ #![ allow( clippy:: needless_pass_by_value) ]
1
2
use super :: utils:: logitems:: { ItemBatch , LogEntry } ;
2
3
use crate :: {
3
4
components:: {
@@ -191,7 +192,7 @@ impl CommitList {
191
192
format ! ( "{}^..{}" , f. hash_short, l. hash_short) ;
192
193
if let Err ( e) = crate :: clipboard:: copy_string ( & yank) {
193
194
self . queue . push ( InternalEvent :: ShowErrorMsg (
194
- copy_fail ( e. to_string ( ) ) ,
195
+ copy_fail ( & e. to_string ( ) ) ,
195
196
) ) ;
196
197
return Err ( e) ;
197
198
}
@@ -215,7 +216,7 @@ impl CommitList {
215
216
216
217
if let Err ( e) = crate :: clipboard:: copy_string ( & separate) {
217
218
self . queue . push ( InternalEvent :: ShowErrorMsg (
218
- copy_fail ( e. to_string ( ) ) ,
219
+ copy_fail ( & e. to_string ( ) ) ,
219
220
) ) ;
220
221
return Err ( e) ;
221
222
}
@@ -238,7 +239,7 @@ impl CommitList {
238
239
crate :: clipboard:: copy_string ( & e. hash_short )
239
240
{
240
241
self . queue . push ( InternalEvent :: ShowErrorMsg (
241
- copy_fail ( e. to_string ( ) ) ,
242
+ copy_fail ( & e. to_string ( ) ) ,
242
243
) ) ;
243
244
return Err ( e) ;
244
245
}
@@ -255,7 +256,7 @@ impl CommitList {
255
256
crate :: clipboard:: copy_string ( & e. hash_short )
256
257
{
257
258
self . queue . push ( InternalEvent :: ShowErrorMsg (
258
- copy_fail ( e. to_string ( ) ) ,
259
+ copy_fail ( & e. to_string ( ) ) ,
259
260
) ) ;
260
261
return Err ( e) ;
261
262
}
@@ -406,7 +407,7 @@ impl CommitList {
406
407
txt. push ( splitter. clone ( ) ) ;
407
408
408
409
let author_width =
409
- ( width. saturating_sub ( 19 ) / 3 ) . max ( 3 ) . min ( 20 ) ;
410
+ ( width. saturating_sub ( 19 ) / 3 ) . clamp ( 3 , 20 ) ;
410
411
let author = string_width_align ( & e. author , author_width) ;
411
412
412
413
// commit author
@@ -418,18 +419,14 @@ impl CommitList {
418
419
txt. push ( splitter. clone ( ) ) ;
419
420
420
421
// commit tags
421
- if let Some ( tags) = tags {
422
- txt. push ( splitter. clone ( ) ) ;
423
- txt. push ( Span :: styled ( tags, theme. tags ( selected) ) ) ;
424
- }
425
-
426
- if let Some ( branches) = branches {
427
- txt. push ( splitter. clone ( ) ) ;
428
- txt. push ( Span :: styled (
429
- branches,
430
- theme. branch ( selected, true ) ,
431
- ) ) ;
432
- }
422
+ txt. push ( Span :: styled (
423
+ Cow :: from (
424
+ tags. map_or_else ( String :: new, |tags| {
425
+ format ! ( " {tags}" )
426
+ } ) ,
427
+ ) ,
428
+ theme. tags ( selected) ,
429
+ ) ) ;
433
430
434
431
txt. push ( splitter) ;
435
432
@@ -439,7 +436,7 @@ impl CommitList {
439
436
440
437
// commit msg
441
438
txt. push ( Span :: styled (
442
- format ! ( "{:w $}" , & e. msg, w = message_width ) ,
439
+ format ! ( "{:message_width $}" , & e. msg) ,
443
440
theme. text ( true , selected) ,
444
441
) ) ;
445
442
@@ -474,7 +471,7 @@ impl CommitList {
474
471
let branches = self . branches . get ( & e. id ) . map ( |names| {
475
472
names
476
473
. iter ( )
477
- . map ( |name| format ! ( "{{{}}}" , name ) )
474
+ . map ( |name| format ! ( "{{{name }}}" ) )
478
475
. join ( " " )
479
476
} ) ;
480
477
@@ -542,7 +539,7 @@ impl DrawableComponent for CommitList {
542
539
) ) ;
543
540
544
541
let branch_post_fix =
545
- self . branch . as_ref ( ) . map ( |b| format ! ( "- {{{}}}" , b ) ) ;
542
+ self . branch . as_ref ( ) . map ( |b| format ! ( "- {{{b }}}" ) ) ;
546
543
547
544
let title = format ! (
548
545
"{} {}/{} {}" ,
0 commit comments