From 04984415a5fc59ff316830f0ddadf7ed61b765ba Mon Sep 17 00:00:00 2001 From: aycabta Date: Wed, 8 Sep 2021 04:42:26 +0900 Subject: [PATCH] [ruby/irb] Use gem paths to complete "require" https://github.com/ruby/irb/commit/c870b23455 --- lib/irb/completion.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb index 385957c3f1..9a5d8580ac 100644 --- a/lib/irb/completion.rb +++ b/lib/irb/completion.rb @@ -38,8 +38,21 @@ module IRB 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