diff options
author | aycabta <[email protected]> | 2021-09-08 04:42:26 +0900 |
---|---|---|
committer | git <[email protected]> | 2021-09-08 05:23:45 +0900 |
commit | 04984415a5fc59ff316830f0ddadf7ed61b765ba (patch) | |
tree | 3b2f7e9419bd1b2532d47b7e5c77956e80e24d9c /lib/irb | |
parent | e4eb08532942bd50125f02eac5e82c1bc87799f2 (diff) |
[ruby/irb] Use gem paths to complete "require"
https://github.com/ruby/irb/commit/c870b23455
Diffstat (limited to 'lib/irb')
-rw-r--r-- | lib/irb/completion.rb | 15 |
1 files changed, 14 insertions, 1 deletions
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 |