fix(tui): Strip OSC 8 hyperlink sequences in visibleWidth (#396)

This commit is contained in:
cursive 2026-01-02 17:32:36 +08:00 committed by GitHub
parent 209d95870e
commit d97a96493c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -108,7 +108,10 @@ export function visibleWidth(str: string): number {
clean = clean.replace(/\t/g, " ");
}
if (clean.includes("\x1b")) {
// Strip SGR codes (\x1b[...m) and cursor codes (\x1b[...G/K/H/J)
clean = clean.replace(/\x1b\[[0-9;]*[mGKHJ]/g, "");
// Strip OSC 8 hyperlinks: \x1b]8;;URL\x07 and \x1b]8;;\x07
clean = clean.replace(/\x1b\]8;;[^\x07]*\x07/g, "");
}
// Calculate width