Skip to content

Commit e441c13

Browse files
tavianatorsharkdp
authored andcommitted
Allow empty/all-0 styles to override the defaults
1 parent 5507fa5 commit e441c13

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/lib.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,17 @@ impl LsColors {
230230
let parts: Vec<_> = entry.split('=').collect();
231231

232232
if let Some([entry, ansi_style]) = parts.get(0..2) {
233-
if let Some(style) = Style::from_ansi_sequence(ansi_style) {
234-
if entry.starts_with('*') {
233+
let style = Style::from_ansi_sequence(ansi_style);
234+
if let Some(suffix) = entry.strip_prefix('*') {
235+
if let Some(style) = style {
235236
self.suffix_mapping
236-
.push((entry[1..].to_string().to_ascii_lowercase(), style));
237-
} else if let Some(indicator) = Indicator::from(entry) {
237+
.push((suffix.to_string().to_ascii_lowercase(), style));
238+
}
239+
} else if let Some(indicator) = Indicator::from(entry) {
240+
if let Some(style) = style {
238241
self.indicator_mapping.insert(indicator, style);
242+
} else {
243+
self.indicator_mapping.remove(&indicator);
239244
}
240245
}
241246
}

0 commit comments

Comments
 (0)