support hyperlinks separated by BEL characters

This commit is contained in:
Terts Diepraam
2024-02-09 14:28:49 +01:00
parent f08262231a
commit 84b0743e9f
+10 -1
View File
@@ -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
)
}
}