Skip to content

Commit

Permalink
fix highlights with colon
Browse files Browse the repository at this point in the history
Signed-off-by: Chmouel Boudjnah <chmouel@chmouel.com>
  • Loading branch information
chmouel committed Jun 28, 2023
1 parent 346ae7c commit 70a552b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ fn regexp_colorize(regexps: &[String]) -> HashMap<String, Color> {
Color::Blue,
];
for (i, regexp) in regexps.iter().enumerate() {
let mut chosen = colours[i % colours.len()];
let defchosen = colours[i % colours.len()];
let mut chosen = defchosen;
let mut reg = regexp.to_string();
if let Some(colour) = regexp.split(':').next() {
// match colour in colours
Expand All @@ -144,9 +145,13 @@ fn regexp_colorize(regexps: &[String]) -> HashMap<String, Color> {
"green" => Color::Green,
"white" => Color::White,
"black" => Color::Black,
_ => chosen,
_ => Color::Default,
};
reg = regexp.replace(format!("{colour}:").as_str(), "");
if chosen == Color::Default {
chosen = defchosen;
} else {
reg = regexp.replace(format!("{colour}:").as_str(), "");
}
}
regexp_colours.insert(reg, chosen);
}
Expand Down

0 comments on commit 70a552b

Please sign in to comment.