mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
Fixed a bug where Bun.stringWidth() returned 0 for strings containing malformed ANSI escape sequences (e.g., "\x1b[" without closing "m"). The issue was in two places: 1. visibleLatin1WidthExcludeANSIColors: When no closing 'm' was found after '\x1b[', the function returned early without counting remaining characters 2. visibleUTF16WidthFn: Similar issue with unclosed sequences Now treats malformed ANSI sequences as literal text and counts their visible width correctly. Added comprehensive tests for edge cases including: - Unclosed ANSI sequences - Binary data with control characters - Multiple malformed sequences 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>