You've already forked ansi-width
mirror of
https://github.com/uutils/ansi-width.git
synced 2026-06-10 16:13:22 -07:00
support hyperlinks separated by BEL characters
This commit is contained in:
+10
-1
@@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user