Skip to content

Commit 35697f3

Browse files
authored
Avoid slow symbol completion when completion target is an empty symbol (#534)
1 parent 09f1625 commit 35697f3

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎lib/irb/completion.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def self.retrieve_completion_data(input, bind: IRB.conf[:MAIN_CONTEXT].workspace
215215
select_message(receiver, message, proc_candidates | hash_candidates)
216216
end
217217

218-
when /^(:[^:.]*)$/
218+
when /^(:[^:.]+)$/
219219
# Symbol
220220
if doc_namespace
221221
nil

‎test/irb/test_completion.rb‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ def test_complete_symbol
292292
_ = :aiueo
293293
assert_include(IRB::InputCompletor.retrieve_completion_data(":a", bind: binding), ":aiueo")
294294
assert_empty(IRB::InputCompletor.retrieve_completion_data(":irb_unknown_symbol_abcdefg", bind: binding))
295+
# Do not complete empty symbol for performance reason
296+
assert_empty(IRB::InputCompletor.retrieve_completion_data(":", bind: binding))
295297
end
296298

297299
def test_complete_invalid_three_colons

0 commit comments

Comments
 (0)