diff options
author | aycabta <aycabta@gmail.com> | 2019-05-21 00:59:43 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-05-21 01:10:09 +0900 |
commit | 6592f5fcc8e7c6130eba5acf71d2763e7a6d58cf (patch) | |
tree | 16e2143667775d9dde4dbf6d1237e2a86230c146 /lib | |
parent | 583ecd5fc5d96a6a8135776db6e92b8565789fb0 (diff) |
Check bytesize in vi command mode last char back
Diffstat (limited to 'lib')
-rw-r--r-- | lib/reline/line_editor.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 9b06281d6d..f9e2525ef3 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -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 |