Skip to content

Commit b232472

Browse files
committed
Retrieve completed receiver that is a module or class correctly
1 parent 142fc53 commit b232472

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/irb/completion.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ def self.retrieve_completion_data(input, bind: IRB.conf[:MAIN_CONTEXT].workspace
296296
candidates.uniq!
297297
end
298298
if doc_namespace
299-
"#{rec.class.name}#{sep}#{candidates.find{ |i| i == message }}"
299+
rec_class = rec.is_a?(Module) ? rec : rec.class
300+
"#{rec_class.name}#{sep}#{candidates.find{ |i| i == message }}"
300301
else
301302
select_message(receiver, message, candidates, sep)
302303
end

test/irb/test_completion.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,10 @@ def test_complete_variable
8989
assert_include(IRB::InputCompletor.retrieve_completion_data("str_examp", bind: binding), "str_example")
9090
assert_equal(IRB::InputCompletor.retrieve_completion_data("str_example", bind: binding, doc_namespace: true), "String")
9191
end
92+
93+
def test_complete_class_method
94+
assert_include(IRB::InputCompletor.retrieve_completion_data("String.new", bind: binding), "String.new")
95+
assert_equal(IRB::InputCompletor.retrieve_completion_data("String.new", bind: binding, doc_namespace: true), "String.new")
96+
end
9297
end
9398
end

0 commit comments

Comments
 (0)