* Identify emoji where the terminal's wcwidth may disagree with Unicode. * On terminals with correct tables, the CHA we emit is a harmless no-op. * * Two categories: * 1. Newer emoji (Unicode 12.0+) missing from terminal wcwidth tables. * 2. Text-by-default emoji + VS16 (U+FE0F): the base codep
(char: string)
| 1763 | * Examples: ⚔️ (U+2694), ☠️ (U+2620), ❤️ (U+2764). |
| 1764 | */ |
| 1765 | function needsWidthCompensation(char: string): boolean { |
| 1766 | const cp = char.codePointAt(0) |
| 1767 | if (cp === undefined) return false |
| 1768 | // U+1FA70-U+1FAFF: Symbols and Pictographs Extended-A (Unicode 12.0-15.0) |
| 1769 | // U+1FB00-U+1FBFF: Symbols for Legacy Computing (Unicode 13.0) |
| 1770 | if ((cp >= 0x1fa70 && cp <= 0x1faff) || (cp >= 0x1fb00 && cp <= 0x1fbff)) { |
| 1771 | return true |
| 1772 | } |
| 1773 | // Text-by-default emoji with VS16: scan for U+FE0F in multi-codepoint |
| 1774 | // graphemes. Single BMP chars (length 1) and surrogate pairs without VS16 |
| 1775 | // skip this check. VS16 (0xFE0F) can't collide with surrogates (0xD800-0xDFFF). |
| 1776 | if (char.length >= 2) { |
| 1777 | for (let i = 0; i < char.length; i++) { |
| 1778 | if (char.charCodeAt(i) === 0xfe0f) return true |
| 1779 | } |
| 1780 | } |
| 1781 | return false |
| 1782 | } |
| 1783 | |
| 1784 | |
| 1785 | class VirtualScreen { |
no outgoing calls
no test coverage detected