Skip to content

Commit fb22b69

Browse files
committed
Include keycaps in direct basic emoji check
1 parent cc9296e commit fb22b69

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/unicode/display_width.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class DisplayWidth
3131
all: :REGEX_WELL_FORMED,
3232
}
3333
EMOJI_NOT_POSSIBLE = /\A[#*0-9]\z/
34+
REGEX_EMOJI_BASIC_OR_KEYCAP = Regexp.union(Unicode::Emoji::REGEX_BASIC, Unicode::Emoji::REGEX_EMOJI_KEYCAP)
3435

3536
# Returns monospace display width of string
3637
def self.of(string, ambiguous = nil, overwrite = nil, old_options = {}, **options)
@@ -205,8 +206,8 @@ def self.emoji_width(string, sequences = :rgi_fqe)
205206
# Only consider basic emoji
206207

207208
# Ensure all explicit VS16 sequences have width 2
208-
no_emoji_string = string.gsub(Unicode::Emoji::REGEX_BASIC){ |basic_emoji|
209-
if basic_emoji.size == 2 # VS16 present
209+
no_emoji_string = string.gsub(REGEX_EMOJI_BASIC_OR_KEYCAP){ |basic_emoji|
210+
if basic_emoji.size >= 2 # VS16 present
210211
res += 2
211212
""
212213
else

0 commit comments

Comments
 (0)