Skip to content

Commit

Permalink
[ruby/irb] Symbol.all_symbols was adopted by Ruby 1.8.0 or later
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Aug 18, 2020
1 parent 5474007 commit 6f0ef83
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/irb/completion.rb
Expand Up @@ -97,17 +97,13 @@ def self.retrieve_completion_data(input, bind: IRB.conf[:MAIN_CONTEXT].workspace
when /^(:[^:.]*)$/
# Symbol
return nil if doc_namespace
if Symbol.respond_to?(:all_symbols)
sym = $1
candidates = Symbol.all_symbols.collect do |s|
":" + s.id2name.encode(Encoding.default_external)
rescue Encoding::UndefinedConversionError
# ignore
end
candidates.grep(/^#{Regexp.quote(sym)}/)
else
[]
sym = $1
candidates = Symbol.all_symbols.collect do |s|
":" + s.id2name.encode(Encoding.default_external)
rescue Encoding::UndefinedConversionError
# ignore
end
candidates.grep(/^#{Regexp.quote(sym)}/)

when /^::([A-Z][^:\.\(]*)$/
# Absolute Constant or class methods
Expand Down

0 comments on commit 6f0ef83

Please sign in to comment.