From c4d3a5c2253f066874d7a892b927821cdd11bb6b Mon Sep 17 00:00:00 2001 From: taekop Date: Tue, 6 Oct 2026 14:56:45 +0900 Subject: [PATCH] Ignore key bindings to methods inherited from Object Binding a key to a function name such as `exit` in inputrc called Kernel#exit with the key string and raised TypeError. --- lib/reline/line_editor.rb | 2 ++ test/reline/test_macro.rb | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index c8b251f78e..d8af20e54c 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -968,6 +968,8 @@ def wrap_method_call(method_symbol, key, with_operator) return unless respond_to?(method_symbol, true) method_obj = method(method_symbol) + # Not an editing function, e.g. Kernel#exit bound in inputrc + return if Object <= method_obj.owner if @vi_arg and argumentable?(method_obj) if inclusive?(method_obj) method_obj.(key, arg: @vi_arg, inclusive: with_operator) diff --git a/test/reline/test_macro.rb b/test/reline/test_macro.rb index cacdb76c60..60badd0579 100644 --- a/test/reline/test_macro.rb +++ b/test/reline/test_macro.rb @@ -37,4 +37,13 @@ class << @line_editor } assert_equal 'ab', @line_editor.line end + + def test_ignore_method_inherited_from_object + input('abc') + assert_nothing_raised { + input_key("\C-d", :exit) + input_key("\C-d", :sleep) + } + assert_equal 'abc', @line_editor.line + end end