diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb index 232929efe7..3536e8ec87 100644 --- a/lib/irb/completion.rb +++ b/lib/irb/completion.rb @@ -42,9 +42,7 @@ module IRB retrieve_completion_data(input).compact.map{ |i| i.encode(Encoding.default_external) } } - def self.retrieve_completion_data(input, doc_namespace = false) - bind = IRB.conf[:MAIN_CONTEXT].workspace.binding - + def self.retrieve_completion_data(input, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding, doc_namespace: false) case input when /^((["'`]).*\2)\.([^.]*)$/ # String @@ -145,7 +143,7 @@ module IRB select_message(receiver, message, candidates, sep) end - when /^(?-?(0[dbo])?[0-9_]+(\.[0-9_]+)?([eE][+-]?[0-9]+i?|r)?)(?\.|::)(?[^.]*)$/ + when /^(?-?(0[dbo])?[0-9_]+(\.[0-9_]+)?(([eE][+-]?[0-9]+)?i?|r)?)(?\.|::)(?[^.]*)$/ # Numeric receiver = $~[:num] sep = $~[:sep] @@ -277,7 +275,7 @@ module IRB end return end - namespace = retrieve_completion_data(matched, true) + namespace = retrieve_completion_data(matched, doc_namespace: true) return unless matched if namespace.is_a?(Array) out = RDoc::Markup::Document.new diff --git a/test/irb/test_completion.rb b/test/irb/test_completion.rb index 204b321ce1..7cfcbba7fe 100644 --- a/test/irb/test_completion.rb +++ b/test/irb/test_completion.rb @@ -19,5 +19,10 @@ module TestIRB skip "cannot load irb/completion" end end + + def test_complete_numeric + assert_include(IRB::InputCompletor.retrieve_completion_data("1r.positi", bind: binding), "1r.positive?") + assert_empty(IRB::InputCompletor.retrieve_completion_data("1i.positi", bind: binding)) + end end end