1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

The ed_move_to_beg is different from vi_first_print

This commit is contained in:
aycabta 2019-06-03 03:29:19 +09:00
parent 65fdb90325
commit 3428922437
5 changed files with 36 additions and 4 deletions

View file

@ -189,7 +189,7 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
# 93 ] # 93 ]
:ed_unassigned, :ed_unassigned,
# 94 ^ # 94 ^
:ed_move_to_beg, :vi_first_print,
# 95 _ # 95 _
:vi_history_word, :vi_history_word,
# 96 ` # 96 `

View file

@ -1016,8 +1016,12 @@ class Reline::LineEditor
ed_prev_char(key, arg: arg) if arg > 0 ed_prev_char(key, arg: arg) if arg > 0
end end
private def vi_first_print(key)
@byte_pointer, @cursor = Reline::Unicode.vi_first_print(@line)
end
private def ed_move_to_beg(key) private def ed_move_to_beg(key)
@byte_pointer, @cursor = Reline::Unicode.ed_move_to_begin(@line) @byte_pointer = @cursor = 0
end end
private def ed_move_to_end(key) private def ed_move_to_end(key)

View file

@ -407,7 +407,7 @@ class Reline::Unicode
[byte_size, width] [byte_size, width]
end end
def self.ed_move_to_begin(line) def self.vi_first_print(line)
width = 0 width = 0
byte_size = 0 byte_size = 0
while (line.bytesize - 1) > byte_size while (line.bytesize - 1) > byte_size

View file

@ -305,6 +305,17 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
assert_line('aABC012abcd') assert_line('aABC012abcd')
end end
def test_ed_move_to_beg_with_blank
input_keys(' abc')
assert_byte_pointer_size(' abc')
assert_cursor(5)
assert_cursor_max(5)
input_keys("\C-a", false)
assert_byte_pointer_size('')
assert_cursor(0)
assert_cursor_max(5)
end
def test_ed_move_to_end def test_ed_move_to_end
input_keys('abd') input_keys('abd')
assert_byte_pointer_size('abd') assert_byte_pointer_size('abd')

View file

@ -988,7 +988,7 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase
assert_line('abcde foo_bar_baz ABCDE') assert_line('abcde foo_bar_baz ABCDE')
end end
def test_ed_move_to_beg def test_vi_first_print
input_keys("abcde\C-[^") input_keys("abcde\C-[^")
assert_byte_pointer_size('') assert_byte_pointer_size('')
assert_cursor(0) assert_cursor(0)
@ -1005,6 +1005,23 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase
assert_cursor_max(17) assert_cursor_max(17)
end end
def test_ed_move_to_beg
input_keys("abcde\C-[0")
assert_byte_pointer_size('')
assert_cursor(0)
assert_cursor_max(5)
input_keys("0\C-ki")
input_keys(" abcde\C-[0")
assert_byte_pointer_size('')
assert_cursor(0)
assert_cursor_max(6)
input_keys("0\C-ki")
input_keys(" abcde ABCDE \C-[0")
assert_byte_pointer_size('')
assert_cursor(0)
assert_cursor_max(17)
end
def test_vi_delete_meta def test_vi_delete_meta
input_keys("aaa bbb ccc ddd eee\C-[02w") input_keys("aaa bbb ccc ddd eee\C-[02w")
assert_byte_pointer_size('aaa bbb ') assert_byte_pointer_size('aaa bbb ')