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,9 +208,13 @@ class Reline::LineEditor
max_width = @screen_size.last
if @config.editing_mode_is?(:vi_command)
last_byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @line.bytesize)
last_mbchar = @line.byteslice(@line.bytesize - last_byte_size, last_byte_size)
last_width = Reline::Unicode.get_mbchar_width(last_mbchar)
cursor_max = @cursor_max - last_width
if last_byte_size > 0
last_mbchar = @line.byteslice(@line.bytesize - last_byte_size, last_byte_size)
last_width = Reline::Unicode.get_mbchar_width(last_mbchar)
cursor_max = @cursor_max - last_width
else
cursor_max = @cursor_max
end
else
cursor_max = @cursor_max
end