Skip to content

Commit 1c0c06d

Browse files
committed
Operator with arg need to make sure that they take arg to avoid crashing
1 parent fec7da5 commit 1c0c06d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/reline/line_editor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ def wrap_method_call(method_symbol, method_obj, key)
735735
not_insertion = method_symbol != :ed_insert
736736
process_insert(force: not_insertion)
737737
end
738-
if @vi_arg
738+
if @vi_arg and argumentable?(method_obj)
739739
method_obj.(key, arg: @vi_arg)
740740
else
741741
method_obj.(key)

test/reline/test_key_actor_vi.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,19 @@ def test_vi_delete_meta_with_vi_next_char
12281228
assert_line('aaa bbb ___ ddd')
12291229
end
12301230

1231+
def test_vi_delete_meta_with_arg
1232+
input_keys("aaa bbb ccc\C-[02w")
1233+
assert_byte_pointer_size('aaa bbb ')
1234+
assert_cursor(8)
1235+
assert_cursor_max(11)
1236+
assert_line('aaa bbb ccc')
1237+
input_keys('2dl') # TODO This should delete 2 chars.
1238+
assert_byte_pointer_size('aaa bbb ')
1239+
assert_cursor(8)
1240+
assert_cursor_max(10)
1241+
assert_line('aaa bbb cc')
1242+
end
1243+
12311244
def test_vi_change_meta
12321245
input_keys("aaa bbb ccc ddd eee\C-[02w")
12331246
assert_byte_pointer_size('aaa bbb ')

0 commit comments

Comments
 (0)