mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Implement vi_insert_at_bol and vi_add_at_eol
This commit is contained in:
parent
ec0b366a5c
commit
800c2a8e4c
2 changed files with 46 additions and 0 deletions
|
@ -1890,6 +1890,16 @@ class Reline::LineEditor
|
|||
end
|
||||
end
|
||||
|
||||
private def vi_insert_at_bol(key)
|
||||
ed_move_to_beg(key)
|
||||
@config.editing_mode = :vi_insert
|
||||
end
|
||||
|
||||
private def vi_add_at_eol(key)
|
||||
ed_move_to_end(key)
|
||||
@config.editing_mode = :vi_insert
|
||||
end
|
||||
|
||||
private def ed_delete_prev_char(key, arg: 1)
|
||||
deleted = ''
|
||||
arg.times do
|
||||
|
|
|
@ -56,6 +56,42 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase
|
|||
assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
|
||||
end
|
||||
|
||||
def test_vi_insert_at_bol
|
||||
input_keys('I')
|
||||
assert_line('I')
|
||||
assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
|
||||
input_keys("12345\C-[hh")
|
||||
assert_line('I12345')
|
||||
assert_byte_pointer_size('I12')
|
||||
assert_cursor(3)
|
||||
assert_cursor_max(6)
|
||||
assert_instance_of(Reline::KeyActor::ViCommand, @config.editing_mode)
|
||||
input_keys('I')
|
||||
assert_line('I12345')
|
||||
assert_byte_pointer_size('')
|
||||
assert_cursor(0)
|
||||
assert_cursor_max(6)
|
||||
assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
|
||||
end
|
||||
|
||||
def test_vi_add_at_eol
|
||||
input_keys('A')
|
||||
assert_line('A')
|
||||
assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
|
||||
input_keys("12345\C-[hh")
|
||||
assert_line('A12345')
|
||||
assert_byte_pointer_size('A12')
|
||||
assert_cursor(3)
|
||||
assert_cursor_max(6)
|
||||
assert_instance_of(Reline::KeyActor::ViCommand, @config.editing_mode)
|
||||
input_keys('A')
|
||||
assert_line('A12345')
|
||||
assert_byte_pointer_size('A12345')
|
||||
assert_cursor(6)
|
||||
assert_cursor_max(6)
|
||||
assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
|
||||
end
|
||||
|
||||
def test_ed_insert_one
|
||||
input_keys('a')
|
||||
assert_line('a')
|
||||
|
|
Loading…
Reference in a new issue