зеркало из https://github.com/github/ruby.git
[ruby/reline] Use #bytesize for vi_replace_char
This closes ruby/reline#228. https://github.com/ruby/reline/commit/8205fa0b00
This commit is contained in:
Родитель
0db9842b2c
Коммит
78421319d0
|
@ -2478,7 +2478,7 @@ class Reline::LineEditor
|
||||||
byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
|
byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
|
||||||
before = @line.byteslice(0, @byte_pointer)
|
before = @line.byteslice(0, @byte_pointer)
|
||||||
remaining_point = @byte_pointer + byte_size
|
remaining_point = @byte_pointer + byte_size
|
||||||
after = @line.byteslice(remaining_point, @line.size - remaining_point)
|
after = @line.byteslice(remaining_point, @line.bytesize - remaining_point)
|
||||||
@line = before + k.chr + after
|
@line = before + k.chr + after
|
||||||
@cursor_max = calculate_width(@line)
|
@cursor_max = calculate_width(@line)
|
||||||
@waiting_proc = nil
|
@waiting_proc = nil
|
||||||
|
@ -2489,7 +2489,7 @@ class Reline::LineEditor
|
||||||
end
|
end
|
||||||
before = @line.byteslice(0, @byte_pointer)
|
before = @line.byteslice(0, @byte_pointer)
|
||||||
remaining_point = @byte_pointer + byte_size
|
remaining_point = @byte_pointer + byte_size
|
||||||
after = @line.byteslice(remaining_point, @line.size - remaining_point)
|
after = @line.byteslice(remaining_point, @line.bytesize - remaining_point)
|
||||||
replaced = k.chr * arg
|
replaced = k.chr * arg
|
||||||
@line = before + replaced + after
|
@line = before + replaced + after
|
||||||
@byte_pointer += replaced.bytesize
|
@byte_pointer += replaced.bytesize
|
||||||
|
|
|
@ -615,6 +615,24 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase
|
||||||
assert_cursor_max(6)
|
assert_cursor_max(6)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_vi_replace_char_with_mbchar
|
||||||
|
input_keys("あいうえお\C-[0l")
|
||||||
|
assert_line('あいうえお')
|
||||||
|
assert_byte_pointer_size('あ')
|
||||||
|
assert_cursor(2)
|
||||||
|
assert_cursor_max(10)
|
||||||
|
input_keys('rx')
|
||||||
|
assert_line('あxうえお')
|
||||||
|
assert_byte_pointer_size('あ')
|
||||||
|
assert_cursor(2)
|
||||||
|
assert_cursor_max(9)
|
||||||
|
input_keys('l2ry')
|
||||||
|
assert_line('あxyyお')
|
||||||
|
assert_byte_pointer_size('あxyy')
|
||||||
|
assert_cursor(5)
|
||||||
|
assert_cursor_max(7)
|
||||||
|
end
|
||||||
|
|
||||||
def test_vi_next_char
|
def test_vi_next_char
|
||||||
input_keys("abcdef\C-[0")
|
input_keys("abcdef\C-[0")
|
||||||
assert_line('abcdef')
|
assert_line('abcdef')
|
||||||
|
|
Загрузка…
Ссылка в новой задаче