From dc6818de2b879692d7c557a7db41b753a1ec3803 Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Wed, 28 Jun 2023 15:19:44 -0700 Subject: [PATCH] Fix error in charProperties optimization. Result should be 2, not 1. Use a static field to avoid this kind of error (though it might be slightly slower, depending on the compiler/toolchain). --- .../src/UnicodeGraphemeProvider.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/xterm-addon-unicode-graphemes/src/UnicodeGraphemeProvider.ts b/addons/xterm-addon-unicode-graphemes/src/UnicodeGraphemeProvider.ts index 00740dac..8e4b019e 100644 --- a/addons/xterm-addon-unicode-graphemes/src/UnicodeGraphemeProvider.ts +++ b/addons/xterm-addon-unicode-graphemes/src/UnicodeGraphemeProvider.ts @@ -14,14 +14,15 @@ export class UnicodeGraphemeProvider implements IUnicodeVersionProvider { constructor() { } + static readonly plainNarrowProperties: UnicodeCharProperties + = UnicodeService.createPropertyValue(UC.GRAPHEME_BREAK_Other, 1, false); + public charProperties(codepoint: number, preceding: UnicodeCharProperties): UnicodeCharProperties { // Optimize the simple ASCII case, under the condition that // UnicodeService.extractCharKind(preceding) === GRAPHEME_BREAK_Other // (which also covers the case that preceding === 0). - if ((codepoint >= 32 && codepoint < 127) && (preceding >> 3) === 0) { - // Inlined UnicodeService.createPropertyValue(GRAPHEME_BREAK_Other, 1, false) - return 1; + return UnicodeGraphemeProvider.plainNarrowProperties; } let charInfo = UC.getInfo(codepoint);