aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2020-11-02 14:55:15 +0900
committeraycabta <aycabta@gmail.com>2020-12-05 02:58:58 +0900
commit2dc4aca8d18ae8b5159da22c5d02b3052a7ac4ec (patch)
treeb922fbf897eaca8d763aa3d79955791e019aa5df
parent92b22db6a7d943328ef2776fb3b6a6924fc8b496 (diff)
downloadruby-2dc4aca8d18ae8b5159da22c5d02b3052a7ac4ec.tar.gz
[ruby/reline] Operator with arg need to make sure that they take arg to avoid crashing
https://github.com/ruby/reline/commit/1c0c06de1f
-rw-r--r--lib/reline/line_editor.rb2
-rw-r--r--test/reline/test_key_actor_vi.rb13
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index f6cf0c5280..86d57d905b 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -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)
diff --git a/test/reline/test_key_actor_vi.rb b/test/reline/test_key_actor_vi.rb
index f5e542fbbe..a244927999 100644
--- a/test/reline/test_key_actor_vi.rb
+++ b/test/reline/test_key_actor_vi.rb
@@ -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 ')