Skip to content

Commit

Permalink
ansi parser: fix dim / half-bright
Browse files Browse the repository at this point in the history
  • Loading branch information
hellux committed Apr 2, 2024
1 parent 291fc34 commit 6f77668
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/ansi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl Perform for ANSIParser {
match code[0] {
0 => attr = Attr::default(),
1 => attr.effect |= Effect::BOLD,
2 => attr.effect |= !Effect::BOLD,
2 => attr.effect |= Effect::DIM,
4 => attr.effect |= Effect::UNDERLINE,
5 => attr.effect |= Effect::BLINK,
7 => attr.effect |= Effect::REVERSE,
Expand Down Expand Up @@ -606,4 +606,21 @@ mod tests {
assert_eq!(Some(('a', highlight)), it.next());
assert_eq!(None, it.next());
}

#[test]
fn test_ansi_dim() {
// https://github.com/lotabout/skim/issues/495
let input = "\x1B[2mhi\x1b[0m";
let ansistring = ANSIParser::default().parse_ansi(input);
let mut it = ansistring.iter();
let attr = Attr {
effect: Effect::DIM,
..Attr::default()
};

assert_eq!(Some(('h', attr)), it.next());
assert_eq!(Some(('i', attr)), it.next());
assert_eq!(None, it.next());
assert_eq!(ansistring.stripped(), "hi");
}
}

0 comments on commit 6f77668

Please sign in to comment.