summaryrefslogtreecommitdiff
path: root/lib/reline/line_editor.rb
diff options
context:
space:
mode:
authorima1zumi <mariimaizumi5@gmail.com>2020-12-11 22:18:36 +0900
committeraycabta <aycabta@gmail.com>2020-12-11 23:08:06 +0900
commit68d3952c52de3b7cf4aba10d61085244f1bf449b (patch)
tree2bc7a4cb74e5ef3b90dabc53ed263ac3ec356bba /lib/reline/line_editor.rb
parented343c76fbd94dfcd429668b72844e0db87a0b46 (diff)
[ruby/reline] Fix breaking to input Emoji with ZWJ.
https://github.com/ruby/reline/commit/f21dfdbb11
Diffstat (limited to 'lib/reline/line_editor.rb')
-rw-r--r--lib/reline/line_editor.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 236993ffb0..df4903c9c4 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -1265,7 +1265,12 @@ class Reline::LineEditor
else
@line = byteinsert(@line, @byte_pointer, str)
end
+ last_byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
@byte_pointer += bytesize
+ last_mbchar = @line.byteslice((@byte_pointer - bytesize - last_byte_size), last_byte_size)
+ if last_byte_size != 0 and (last_mbchar + str).grapheme_clusters.size == 1
+ width = 0
+ end
@cursor += width
@cursor_max += width
end