Skip to content

Commit 8691a94

Browse files
authored
Improve isDoubleWidthEmojiCluster (#65)
1 parent 68f54fe commit 8691a94

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,26 @@ function isZeroWidthCluster(segment) {
3232
}
3333

3434
function isDoubleWidthEmojiCluster(segment) {
35+
const hasVs16 = segment.includes('\uFE0F');
36+
37+
if (hasVs16) {
38+
return true;
39+
}
40+
3541
const visible = baseVisible(segment);
3642
const baseScalar = visible.codePointAt(0);
3743
const baseChar = String.fromCodePoint(baseScalar);
3844
const baseIsEmojiPresentation = emojiPresentationRegex.test(baseChar);
39-
const hasVs16 = segment.includes('\uFE0F');
4045
const hasVs15 = segment.includes('\uFE0E');
46+
47+
if (baseIsEmojiPresentation && !hasVs15) {
48+
return true;
49+
}
50+
4151
const codePointCount = [...segment].length;
4252
const multiScalarMeaningful = codePointCount > 1 && !(codePointCount === 2 && hasVs15 && !hasVs16);
4353

44-
return hasVs16 || (baseIsEmojiPresentation && !hasVs15) || multiScalarMeaningful;
54+
return multiScalarMeaningful;
4555
}
4656

4757
function trailingHalfwidthWidth(segment, eastAsianWidthOptions) {

0 commit comments

Comments
 (0)