diff --git a/src/lib.rs b/src/lib.rs index 1ee70d8..cf47f5e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,7 @@ pub fn ansi_width(s: &str) -> usize { ']' => { let mut last = c; while let Some(new) = chars.next() { - if new == '\\' && last == ESC { + if new == '\x07' || (new == '\\' && last == ESC) { break; } last = new; @@ -93,4 +93,13 @@ mod tests { 14 ) } + + #[test] + fn nonstandard_hyperlink() { + // This hyperlink has a BEL character in the middle instead of `\x1b\\` + assert_eq!( + ansi_width("\x1b]8;;file://coreutils.md\x07coreutils.md\x1b]8;;\x07"), + 12 + ) + } }