[ruby/reline] Delete the last char of a line by dw

This closes ruby/reline#229.

3f0ae689c4
This commit is contained in:
aycabta 2020-12-24 21:24:35 +09:00
parent 8d5d139afa
commit 0db9842b2c
2 changed files with 26 additions and 3 deletions

View file

@ -459,7 +459,7 @@ class Reline::Unicode
end
def self.vi_forward_word(line, byte_pointer)
if (line.bytesize - 1) > byte_pointer
if line.bytesize > byte_pointer
size = get_next_mbchar_size(line, byte_pointer)
mbchar = line.byteslice(byte_pointer, size)
if mbchar =~ /\w/
@ -474,7 +474,7 @@ class Reline::Unicode
else
return [0, 0]
end
while (line.bytesize - 1) > (byte_pointer + byte_size)
while line.bytesize > (byte_pointer + byte_size)
size = get_next_mbchar_size(line, byte_pointer + byte_size)
mbchar = line.byteslice(byte_pointer + byte_size, size)
case started_by
@ -488,7 +488,7 @@ class Reline::Unicode
width += get_mbchar_width(mbchar)
byte_size += size
end
while (line.bytesize - 1) > (byte_pointer + byte_size)
while line.bytesize > (byte_pointer + byte_size)
size = get_next_mbchar_size(line, byte_pointer + byte_size)
mbchar = line.byteslice(byte_pointer + byte_size, size)
break if mbchar =~ /\S/