Fix crash on unicode character (#16420)

This commit is contained in:
christine betts
2026-01-12 11:52:19 -05:00
committed by GitHub
parent 7b7f2fc69e
commit 64c75cb767
2 changed files with 27 additions and 2 deletions

View File

@@ -136,7 +136,15 @@ export const getCachedStringWidth = (str: string): number => {
return stringWidthCache.get(str)!;
}
const width = stringWidth(str);
let width: number;
try {
width = stringWidth(str);
} catch {
// Fallback for characters that cause string-width to crash (e.g. U+0602)
// See: https://github.com/google-gemini/gemini-cli/issues/16418
width = toCodePoints(stripAnsi(str)).length;
}
stringWidthCache.set(str, width);
return width;