- Added string-width library for proper terminal column width calculation - Fixed wrapLine() to split by newlines before wrapping (like Text component) - Fixed Loader interval leak by stopping before container removal - Changed loader message from 'Loading...' to 'Working...'
13 lines
354 B
TypeScript
13 lines
354 B
TypeScript
import stringWidth from "string-width";
|
|
|
|
/**
|
|
* Calculate the visible width of a string in terminal columns.
|
|
* This correctly handles:
|
|
* - ANSI escape codes (ignored)
|
|
* - Emojis and wide characters (counted as 2 columns)
|
|
* - Combining characters (counted correctly)
|
|
*/
|
|
export function visibleWidth(str: string): number {
|
|
return stringWidth(str);
|
|
}
|