Skip to content

Commit

Permalink
Use gem paths to complete "require"
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Sep 7, 2021
1 parent 9ff0b1b commit c870b23
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/irb/completion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,21 @@ def defined? do

BASIC_WORD_BREAK_CHARACTERS = " \t\n`><=;|&{("

def self.retrieve_gem_and_system_load_path
gem_paths = Gem::Specification.latest_specs(true).map { |s|
s.require_paths.map { |p|
if File.absolute_path?(p)
p
else
File.join(s.full_gem_path, p)
end
}
}.flatten
(gem_paths + $LOAD_PATH).uniq.sort
end

def self.retrieve_files_to_require_from_load_path
@@files_from_load_path ||= $LOAD_PATH.flat_map { |path|
@@files_from_load_path ||= retrieve_gem_and_system_load_path.flat_map { |path|
begin
Dir.glob("**/*.{rb,#{RbConfig::CONFIG['DLEXT']}}", base: path)
rescue Errno::ENOENT
Expand Down

0 comments on commit c870b23

Please sign in to comment.