Skip to content

Commit

Permalink
Include keycaps in direct basic emoji check
Browse files Browse the repository at this point in the history
  • Loading branch information
janlelis committed Nov 12, 2024
1 parent cc9296e commit fb22b69
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/unicode/display_width.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class DisplayWidth
all: :REGEX_WELL_FORMED,
}
EMOJI_NOT_POSSIBLE = /\A[#*0-9]\z/
REGEX_EMOJI_BASIC_OR_KEYCAP = Regexp.union(Unicode::Emoji::REGEX_BASIC, Unicode::Emoji::REGEX_EMOJI_KEYCAP)

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

# Ensure all explicit VS16 sequences have width 2
no_emoji_string = string.gsub(Unicode::Emoji::REGEX_BASIC){ |basic_emoji|
if basic_emoji.size == 2 # VS16 present
no_emoji_string = string.gsub(REGEX_EMOJI_BASIC_OR_KEYCAP){ |basic_emoji|
if basic_emoji.size >= 2 # VS16 present
res += 2
""
else
Expand Down

0 comments on commit fb22b69

Please sign in to comment.