1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Check bytesize in vi command mode last char back

This commit is contained in:
aycabta 2019-05-21 00:59:43 +09:00
parent 583ecd5fc5
commit 6592f5fcc8

View file

@ -208,12 +208,16 @@ class Reline::LineEditor
max_width = @screen_size.last max_width = @screen_size.last
if @config.editing_mode_is?(:vi_command) if @config.editing_mode_is?(:vi_command)
last_byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @line.bytesize) last_byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @line.bytesize)
if last_byte_size > 0
last_mbchar = @line.byteslice(@line.bytesize - last_byte_size, last_byte_size) last_mbchar = @line.byteslice(@line.bytesize - last_byte_size, last_byte_size)
last_width = Reline::Unicode.get_mbchar_width(last_mbchar) last_width = Reline::Unicode.get_mbchar_width(last_mbchar)
cursor_max = @cursor_max - last_width cursor_max = @cursor_max - last_width
else else
cursor_max = @cursor_max cursor_max = @cursor_max
end end
else
cursor_max = @cursor_max
end
@line.encode(Encoding::UTF_8).grapheme_clusters.each do |gc| @line.encode(Encoding::UTF_8).grapheme_clusters.each do |gc|
mbchar_width = Reline::Unicode.get_mbchar_width(gc) mbchar_width = Reline::Unicode.get_mbchar_width(gc)
now = new_cursor + mbchar_width now = new_cursor + mbchar_width