MCPcopy Index your code
hub / github.com/codeaashu/claude-code / needsWidthCompensation

Function needsWidthCompensation

src/ink/log-update.ts:733–750  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

731 * Examples: ⚔️ (U+2694), ☠️ (U+2620), ❤️ (U+2764).
732 */
733function needsWidthCompensation(char: string): boolean {
734 const cp = char.codePointAt(0)
735 if (cp === undefined) return false
736 // U+1FA70-U+1FAFF: Symbols and Pictographs Extended-A (Unicode 12.0-15.0)
737 // U+1FB00-U+1FBFF: Symbols for Legacy Computing (Unicode 13.0)
738 if ((cp >= 0x1fa70 && cp <= 0x1faff) || (cp >= 0x1fb00 && cp <= 0x1fbff)) {
739 return true
740 }
741 // Text-by-default emoji with VS16: scan for U+FE0F in multi-codepoint
742 // graphemes. Single BMP chars (length 1) and surrogate pairs without VS16
743 // skip this check. VS16 (0xFE0F) can't collide with surrogates (0xD800-0xDFFF).
744 if (char.length >= 2) {
745 for (let i = 0; i < char.length; i++) {
746 if (char.charCodeAt(i) === 0xfe0f) return true
747 }
748 }
749 return false
750}
751
752class VirtualScreen {
753 // Public for direct mutation by writeCellWithStyleStr (avoids txn overhead).

Callers 1

writeCellWithStyleStrFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected