From 6bad98237e359a4ca819c472c8df8c03194e1bc9 Mon Sep 17 00:00:00 2001 From: Nicolas TOUSSAINT Date: Wed, 29 Apr 2026 11:24:10 +0200 Subject: [PATCH] Fix #7 - strip links related characters before calculating string length --- src/prezo/layout.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/prezo/layout.py b/src/prezo/layout.py index c951e41..362b494 100644 --- a/src/prezo/layout.py +++ b/src/prezo/layout.py @@ -1084,4 +1084,11 @@ def _visible_length(text: str) -> int: """ # Strip ANSI codes first, then calculate cell width clean_text = _ANSI_PATTERN.sub("", text) + + # Strip OSC 8 hyperlink opening: \x1b]8;id=ID;URL\x1b\\ + clean_text = re.sub(r'\x1b\]8;id=[0-9]+;[^\x1b]*\x1b\\', '', clean_text) + + # Strip OSC 8 hyperlink closing: \x1b]8;;\x1b\\ + clean_text = re.sub(r'\x1b\]8;;\x1b\\', '', clean_text) + return cell_len(clean_text)