mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Cursor can't move to eol when vi command mode
This commit is contained in:
parent
f659e2f9bf
commit
9f49ff4965
1 changed files with 9 additions and 1 deletions
|
@ -206,10 +206,18 @@ class Reline::LineEditor
|
||||||
new_byte_pointer = 0
|
new_byte_pointer = 0
|
||||||
height = 1
|
height = 1
|
||||||
max_width = @screen_size.last
|
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|
|
@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
|
||||||
if now > @cursor_max or now > @cursor
|
if now > cursor_max or now > @cursor
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
new_cursor += mbchar_width
|
new_cursor += mbchar_width
|
||||||
|
|
Loading…
Add table
Reference in a new issue