diff options
author | aycabta <[email protected]> | 2021-09-08 05:07:24 +0900 |
---|---|---|
committer | git <[email protected]> | 2021-09-08 05:23:56 +0900 |
commit | bc24af0f355c71ccc8e57ec95f771fa0737bd27d (patch) | |
tree | 8505eb94692543ce1f60701b69fb7e8c5a91ba13 /lib/irb/completion.rb | |
parent | c5e8088c7e1c67566f0c2fed0c377c4c8b1990c2 (diff) |
[ruby/irb] Show lib name first because it's the most common use case
https://github.com/ruby/irb/commit/74d635758b
Diffstat (limited to 'lib/irb/completion.rb')
-rw-r--r-- | lib/irb/completion.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb index 597dcdaa81..812ebb09e7 100644 --- a/lib/irb/completion.rb +++ b/lib/irb/completion.rb @@ -64,15 +64,18 @@ module IRB end def self.retrieve_files_to_require_from_load_path - @@files_from_load_path ||= retrieve_gem_and_system_load_path.flat_map { |path| + @@files_from_load_path ||= retrieve_gem_and_system_load_path.map { |path| begin Dir.glob("**/*.{rb,#{RbConfig::CONFIG['DLEXT']}}", base: path) rescue Errno::ENOENT [] end - }.uniq.map { |path| - path.sub(/\.(rb|#{RbConfig::CONFIG['DLEXT']})\z/, '') - } + }.inject([]) { |result, names| + shortest, *rest = names.map{ |n| n.sub(/\.(rb|#{RbConfig::CONFIG['DLEXT']})\z/, '') }.sort + result.unshift(shortest) if shortest + result.concat(rest) + result + }.uniq end def self.retrieve_files_to_require_relative_from_current_dir |