diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb index c7c0fb99e..385957c3f 100644 --- a/lib/irb/completion.rb +++ b/lib/irb/completion.rb @@ -296,7 +296,8 @@ def self.retrieve_completion_data(input, bind: IRB.conf[:MAIN_CONTEXT].workspace candidates.uniq! end if doc_namespace - "#{rec.class.name}#{sep}#{candidates.find{ |i| i == message }}" + rec_class = rec.is_a?(Module) ? rec : rec.class + "#{rec_class.name}#{sep}#{candidates.find{ |i| i == message }}" else select_message(receiver, message, candidates, sep) end diff --git a/test/irb/test_completion.rb b/test/irb/test_completion.rb index 260b8a889..a661d68c5 100644 --- a/test/irb/test_completion.rb +++ b/test/irb/test_completion.rb @@ -89,5 +89,10 @@ def test_complete_variable assert_include(IRB::InputCompletor.retrieve_completion_data("str_examp", bind: binding), "str_example") assert_equal(IRB::InputCompletor.retrieve_completion_data("str_example", bind: binding, doc_namespace: true), "String") end + + def test_complete_class_method + assert_include(IRB::InputCompletor.retrieve_completion_data("String.new", bind: binding), "String.new") + assert_equal(IRB::InputCompletor.retrieve_completion_data("String.new", bind: binding, doc_namespace: true), "String.new") + end end end