1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/irb] Retrieve completed receiver that is a module or class correctly

https://github.com/ruby/irb/commit/b2324727e1
This commit is contained in:
aycabta 2021-09-04 05:33:03 +09:00 committed by git
parent f6bc4b9b97
commit 6fa37d2666
2 changed files with 7 additions and 1 deletions

View file

@ -296,7 +296,8 @@ module IRB
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

View file

@ -89,5 +89,10 @@ module TestIRB
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