diff options
author | aycabta <aycabta@gmail.com> | 2019-05-20 07:45:36 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-05-20 07:50:14 +0900 |
commit | 9f49ff4965da8b05887912506dff7d0d20388550 (patch) | |
tree | 44a4efe6fa092f1892d6d24f4156660e7b6f9e8e /lib | |
parent | f659e2f9bf0c7d0351a80dc284a384a948bd67dd (diff) |
Cursor can't move to eol when vi command mode
Diffstat (limited to 'lib')
-rw-r--r-- | lib/reline/line_editor.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 09ac94fa39..9b06281d6d 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -206,10 +206,18 @@ class Reline::LineEditor new_byte_pointer = 0 height = 1 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 + else + cursor_max = @cursor_max + end @line.encode(Encoding::UTF_8).grapheme_clusters.each do |gc| mbchar_width = Reline::Unicode.get_mbchar_width(gc) now = new_cursor + mbchar_width - if now > @cursor_max or now > @cursor + if now > cursor_max or now > @cursor break end new_cursor += mbchar_width |