@@ -34,8 +34,6 @@ class DisplayWidth
34
34
rgi_at : :REGEX_INCLUDE_MQE_UQE ,
35
35
possible : :REGEX_WELL_FORMED ,
36
36
}
37
- # REGEX_NEEDS_EMOJI_HANDLING: ZWJ, VS16, MODIFIER, KEYCAP
38
- REGEX_EMOJI_NOT_POSSIBLE = /\A [#*0-9]\z /
39
37
REGEX_EMOJI_VS16 = Regexp . union (
40
38
Regexp . compile (
41
39
Unicode ::Emoji ::REGEX_TEXT_PRESENTATION . source +
@@ -68,7 +66,7 @@ def self.of(string, ambiguous = nil, overwrite = nil, old_options = {}, **option
68
66
return width + string . size
69
67
end
70
68
71
- # Retrieve Emoji width, maybe: add quick check using REGEX_NEEDS_EMOJI_HANDLING
69
+ # Retrieve Emoji width
72
70
if options [ :emoji ] != :none
73
71
e_width , string = emoji_width (
74
72
string ,
@@ -167,13 +165,9 @@ def self.emoji_width_via_possible(string, emoji_set_regex, strict_eaw = false, a
167
165
res = 0
168
166
169
167
# For each string possibly an emoji
170
- no_emoji_string = string . gsub ( Unicode ::Emoji ::REGEX_POSSIBLE ) { |emoji_candidate |
171
- # Skip notorious false positives
172
- if REGEX_EMOJI_NOT_POSSIBLE . match? ( emoji_candidate )
173
- emoji_candidate
174
-
168
+ no_emoji_string = string . gsub ( REGEX_EMOJI_ALL_SEQUENCES_AND_VS16 ) { |emoji_candidate |
175
169
# Check if we have a combined Emoji with width 2 (or EAW an Apple Terminal)
176
- elsif emoji_candidate == emoji_candidate [ emoji_set_regex ]
170
+ if emoji_candidate == emoji_candidate [ emoji_set_regex ]
177
171
if strict_eaw
178
172
res += self . of ( emoji_candidate [ 0 ] , ambiguous , emoji : false )
179
173
else
0 commit comments