Skip to content

Commit

Permalink
Apply active style to active item
Browse files Browse the repository at this point in the history
  • Loading branch information
deg0nz committed May 14, 2022
1 parent 3f16bde commit c891ca1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl Default for ColorfulTheme {
#[cfg(feature = "fuzzy-select")]
fuzzy_cursor_style: Style::new().for_stderr().black().on_white(),
#[cfg(feature = "fuzzy-select")]
fuzzy_match_highlight_style: Style::new().for_stderr().bold().yellow(),
fuzzy_match_highlight_style: Style::new().for_stderr().bold(),
inline_selections: true,
}
}
Expand Down Expand Up @@ -625,15 +625,24 @@ impl Theme for ColorfulTheme {
matcher: &SkimMatcherV2,
search_term: &str,
) -> fmt::Result {
write!(f, "{} ", if active { ">" } else { " " })?;
write!(f, "{} ", if active { &self.active_item_prefix } else { &self.inactive_item_prefix })?;

if highlight_matches {
if let Some((_score, indices)) = matcher.fuzzy_indices(text, &search_term) {
for (idx, c) in text.chars().into_iter().enumerate() {
if indices.contains(&idx) {
write!(f, "{}", self.fuzzy_match_highlight_style.apply_to(c))?;
if active {
write!(f, "{}", self.active_item_style.apply_to(self.fuzzy_match_highlight_style.apply_to(c)))?;
} else {
// write!(f, "{}", self.fuzzy_match_highlight_style.apply_to(c).yellow())?;
write!(f, "{}", self.fuzzy_match_highlight_style.apply_to(c))?;
}
} else {
write!(f, "{}", c)?;
if active {
write!(f, "{}", self.active_item_style.apply_to(c))?;
} else {
write!(f, "{}", c)?;
}
}
}

Expand Down

0 comments on commit c891ca1

Please sign in to comment.