Skip to content

Commit 53c28fd

Browse files
committed
cleanup
1 parent 575a94c commit 53c28fd

File tree

1 file changed

+26
-37
lines changed

1 file changed

+26
-37
lines changed

Diff for: src/components/commitlist.rs

+26-37
Original file line numberDiff line numberDiff line change
@@ -332,22 +332,34 @@ impl CommitList {
332332
txt.push(splitter.clone());
333333
}
334334

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+
335354
// 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));
342356

343357
txt.push(splitter.clone());
344358

345359
// commit timestamp
346360
txt.push(Span::styled(
347361
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,
351363
));
352364

353365
txt.push(splitter.clone());
@@ -357,44 +369,23 @@ impl CommitList {
357369
let author = string_width_align(&e.author, author_width);
358370

359371
// 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));
366373

367374
txt.push(splitter.clone());
368375

369376
// commit tags
370377
if let Some(tags) = tags {
371378
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));
378380
}
379381

380382
if let Some(local_branches) = local_branches {
381383
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));
388385
}
389-
390386
if let Some(remote_branches) = remote_branches {
391387
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));
398389
}
399390

400391
txt.push(splitter);
@@ -406,9 +397,7 @@ impl CommitList {
406397
// commit msg
407398
txt.push(Span::styled(
408399
format!("{:message_width$}", &e.msg),
409-
normal
410-
.then(|| theme.text(true, selected))
411-
.unwrap_or_else(|| theme.commit_unhighlighted()),
400+
style_msg,
412401
));
413402

414403
Line::from(txt)

0 commit comments

Comments
 (0)