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

[ruby/reline] Operator with arg need to make sure that they take arg to avoid crashing

https://github.com/ruby/reline/commit/1c0c06de1f
This commit is contained in:
aycabta 2020-11-02 14:55:15 +09:00
parent 92b22db6a7
commit 2dc4aca8d1
2 changed files with 14 additions and 1 deletions

View file

@ -735,7 +735,7 @@ class Reline::LineEditor
not_insertion = method_symbol != :ed_insert
process_insert(force: not_insertion)
end
if @vi_arg
if @vi_arg and argumentable?(method_obj)
method_obj.(key, arg: @vi_arg)
else
method_obj.(key)

View file

@ -1228,6 +1228,19 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase
assert_line('aaa bbb ___ ddd')
end
def test_vi_delete_meta_with_arg
input_keys("aaa bbb ccc\C-[02w")
assert_byte_pointer_size('aaa bbb ')
assert_cursor(8)
assert_cursor_max(11)
assert_line('aaa bbb ccc')
input_keys('2dl') # TODO This should delete 2 chars.
assert_byte_pointer_size('aaa bbb ')
assert_cursor(8)
assert_cursor_max(10)
assert_line('aaa bbb cc')
end
def test_vi_change_meta
input_keys("aaa bbb ccc ddd eee\C-[02w")
assert_byte_pointer_size('aaa bbb ')