diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-06-02 13:10:03 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-06-03 01:35:48 +0900 |
commit | 3457ce448655a3c2e52793186f62298903ddc26b (patch) | |
tree | 3c79a3abfde15147dfb66fa504ef9a8a8ff9cbdc /lib | |
parent | f4b060d8d7f927306cbbe24df888a09112acd4c8 (diff) | |
download | ruby-3457ce448655a3c2e52793186f62298903ddc26b.tar.gz |
Fix ArgumentError in aliased macro
Closes: https://github.com/ruby/ruby/pull/2221
Diffstat (limited to 'lib')
-rw-r--r-- | lib/reline/line_editor.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 3fb4480990..e4acdb967d 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -641,6 +641,10 @@ class Reline::LineEditor end end + private def argumentable?(method_obj) + method_obj and method_obj.parameters.length != 1 + end + private def process_key(key, method_symbol) if method_symbol and respond_to?(method_symbol, true) method_obj = method(method_symbol) @@ -648,14 +652,20 @@ class Reline::LineEditor method_obj = nil end if method_symbol and key.is_a?(Symbol) - method_obj&.(key, arg: @vi_arg) + if @vi_arg and argumentable?(method_obj) + run_for_operators(key, method_symbol) do + method_obj.(key, arg: @vi_arg) + end + else + method_obj&.(key) + end @kill_ring.process @vi_arg = nil elsif @vi_arg if key.chr =~ /[0-9]/ ed_argument_digit(key) else - if ARGUMENTABLE.include?(method_symbol) and method_obj + if argumentable?(method_obj) run_for_operators(key, method_symbol) do method_obj.(key, arg: @vi_arg) end |