Skip to content

Commit a54567f

Browse files
authored
Fix some styles not being reflected correctly in the commit list (#95)
* Fix subject fg settings not being reflected correctly * Fix refs match highlighting not reflecting modifiers correctly
1 parent cbd2fc9 commit a54567f

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/widget/commit_list.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use ratatui::{
77
buffer::Buffer,
88
crossterm::event::{Event, KeyEvent},
99
layout::{Constraint, Layout, Rect},
10-
style::{Color, Style, Stylize},
10+
style::{Color, Modifier, Style, Stylize},
1111
text::{Line, Span},
1212
widgets::{List, ListItem, StatefulWidget, Widget},
1313
};
@@ -809,11 +809,12 @@ impl CommitList<'_> {
809809
subject,
810810
pos,
811811
self.color_theme.list_subject_fg,
812+
Modifier::empty(),
812813
self.color_theme,
813814
truncate,
814815
)
815816
} else {
816-
vec![subject.into()]
817+
vec![subject.fg(self.color_theme.list_subject_fg)]
817818
};
818819

819820
spans.extend(sub_spans)
@@ -844,6 +845,7 @@ impl CommitList<'_> {
844845
name,
845846
pos,
846847
self.color_theme.list_name_fg,
848+
Modifier::empty(),
847849
self.color_theme,
848850
truncate,
849851
)
@@ -870,6 +872,7 @@ impl CommitList<'_> {
870872
hash,
871873
pos,
872874
self.color_theme.list_hash_fg,
875+
Modifier::empty(),
873876
self.color_theme,
874877
false,
875878
)
@@ -978,7 +981,16 @@ fn refs_spans<'a>(
978981
.map(|(name, fg)| {
979982
let spans = refs_matches
980983
.get(name)
981-
.map(|pos| highlighted_spans(name.to_string(), pos.clone(), fg, color_theme, false))
984+
.map(|pos| {
985+
highlighted_spans(
986+
name.to_string(),
987+
pos.clone(),
988+
fg,
989+
Modifier::BOLD,
990+
color_theme,
991+
false,
992+
)
993+
})
982994
.unwrap_or_else(|| vec![Span::raw(name).fg(fg).bold()]);
983995
(spans, name)
984996
})
@@ -1021,16 +1033,18 @@ fn highlighted_spans(
10211033
s: String,
10221034
pos: SearchMatchPosition,
10231035
base_fg: Color,
1036+
base_modifier: Modifier,
10241037
color_theme: &ColorTheme,
10251038
truncate: bool,
10261039
) -> Vec<Span<'static>> {
10271040
let mut hm = highlight_matched_text(s)
10281041
.matched_indices(pos.matched_indices)
1029-
.not_matched_style(Style::default().fg(base_fg))
1042+
.not_matched_style(Style::default().fg(base_fg).add_modifier(base_modifier))
10301043
.matched_style(
10311044
Style::default()
10321045
.fg(color_theme.list_match_fg)
1033-
.bg(color_theme.list_match_bg),
1046+
.bg(color_theme.list_match_bg)
1047+
.add_modifier(base_modifier),
10341048
);
10351049
if truncate {
10361050
hm = hm.ellipsis(ELLIPSIS);

0 commit comments

Comments
 (0)