@@ -332,22 +332,34 @@ impl CommitList {
332
332
txt. push ( splitter. clone ( ) ) ;
333
333
}
334
334
335
+ let style_hash = normal
336
+ . then ( || theme. commit_hash ( selected) )
337
+ . unwrap_or_else ( || theme. commit_unhighlighted ( ) ) ;
338
+ let style_time = normal
339
+ . then ( || theme. commit_time ( selected) )
340
+ . unwrap_or_else ( || theme. commit_unhighlighted ( ) ) ;
341
+ let style_author = normal
342
+ . then ( || theme. commit_author ( selected) )
343
+ . unwrap_or_else ( || theme. commit_unhighlighted ( ) ) ;
344
+ let style_tags = normal
345
+ . then ( || theme. tags ( selected) )
346
+ . unwrap_or_else ( || theme. commit_unhighlighted ( ) ) ;
347
+ let style_branches = normal
348
+ . then ( || theme. branch ( selected, true ) )
349
+ . unwrap_or_else ( || theme. commit_unhighlighted ( ) ) ;
350
+ let style_msg = normal
351
+ . then ( || theme. text ( true , selected) )
352
+ . unwrap_or_else ( || theme. commit_unhighlighted ( ) ) ;
353
+
335
354
// commit hash
336
- txt. push ( Span :: styled (
337
- Cow :: from ( & * e. hash_short ) ,
338
- normal
339
- . then ( || theme. commit_hash ( selected) )
340
- . unwrap_or_else ( || theme. commit_unhighlighted ( ) ) ,
341
- ) ) ;
355
+ txt. push ( Span :: styled ( Cow :: from ( & * e. hash_short ) , style_hash) ) ;
342
356
343
357
txt. push ( splitter. clone ( ) ) ;
344
358
345
359
// commit timestamp
346
360
txt. push ( Span :: styled (
347
361
Cow :: from ( e. time_to_string ( now) ) ,
348
- normal
349
- . then ( || theme. commit_time ( selected) )
350
- . unwrap_or_else ( || theme. commit_unhighlighted ( ) ) ,
362
+ style_time,
351
363
) ) ;
352
364
353
365
txt. push ( splitter. clone ( ) ) ;
@@ -357,44 +369,23 @@ impl CommitList {
357
369
let author = string_width_align ( & e. author , author_width) ;
358
370
359
371
// commit author
360
- txt. push ( Span :: styled :: < String > (
361
- author,
362
- normal
363
- . then ( || theme. commit_author ( selected) )
364
- . unwrap_or_else ( || theme. commit_unhighlighted ( ) ) ,
365
- ) ) ;
372
+ txt. push ( Span :: styled :: < String > ( author, style_author) ) ;
366
373
367
374
txt. push ( splitter. clone ( ) ) ;
368
375
369
376
// commit tags
370
377
if let Some ( tags) = tags {
371
378
txt. push ( splitter. clone ( ) ) ;
372
- txt. push ( Span :: styled (
373
- tags,
374
- normal
375
- . then ( || theme. tags ( selected) )
376
- . unwrap_or_else ( || theme. commit_unhighlighted ( ) ) ,
377
- ) ) ;
379
+ txt. push ( Span :: styled ( tags, style_tags) ) ;
378
380
}
379
381
380
382
if let Some ( local_branches) = local_branches {
381
383
txt. push ( splitter. clone ( ) ) ;
382
- txt. push ( Span :: styled (
383
- local_branches,
384
- normal
385
- . then ( || theme. branch ( selected, true ) )
386
- . unwrap_or_else ( || theme. commit_unhighlighted ( ) ) ,
387
- ) ) ;
384
+ txt. push ( Span :: styled ( local_branches, style_branches) ) ;
388
385
}
389
-
390
386
if let Some ( remote_branches) = remote_branches {
391
387
txt. push ( splitter. clone ( ) ) ;
392
- txt. push ( Span :: styled (
393
- remote_branches,
394
- normal
395
- . then ( || theme. branch ( selected, true ) )
396
- . unwrap_or_else ( || theme. commit_unhighlighted ( ) ) ,
397
- ) ) ;
388
+ txt. push ( Span :: styled ( remote_branches, style_branches) ) ;
398
389
}
399
390
400
391
txt. push ( splitter) ;
@@ -406,9 +397,7 @@ impl CommitList {
406
397
// commit msg
407
398
txt. push ( Span :: styled (
408
399
format ! ( "{:message_width$}" , & e. msg) ,
409
- normal
410
- . then ( || theme. text ( true , selected) )
411
- . unwrap_or_else ( || theme. commit_unhighlighted ( ) ) ,
400
+ style_msg,
412
401
) ) ;
413
402
414
403
Line :: from ( txt)
0 commit comments