Skip to content

Commit

Permalink
Retrieve completed receiver that is a module or class correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Sep 3, 2021
1 parent 142fc53 commit b232472
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/irb/completion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/irb/test_completion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b232472

Please sign in to comment.