Skip to content

Commit

Permalink
support hyperlinks separated by BEL characters
Browse files Browse the repository at this point in the history
  • Loading branch information
tertsdiepraam committed Feb 9, 2024
1 parent f082622 commit 84b0743
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
)
}
}

0 comments on commit 84b0743

Please sign in to comment.