Skip to content

Commit

Permalink
Dedupe require paths completion
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Dec 3, 2023
1 parent 6d0a9d1 commit ec66984
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in repl_type_completor.gemspec
gemspec

gem 'irb', '>= 1.10.0'
gem 'rake', '~> 13.0'
gem 'test-unit'
gem 'test-unit-ruby-core'
Expand Down
2 changes: 1 addition & 1 deletion lib/repl_type_completor/require_paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def require_completions(target_path)
with_cache [:requireable_paths, base_dir] do
requireable_paths(base_dir)
end
end.sort
end.uniq.sort
end
paths.filter_map do |path|
[*dir, path].join('/') if path.start_with?(target)
Expand Down
1 change: 1 addition & 0 deletions test/repl_type_completor/test_require_paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def test_require_paths
assert_include ReplTypeCompletor::RequirePaths.require_completions('repl_type_com'), 'repl_type_completor'
assert_include ReplTypeCompletor::RequirePaths.require_completions('repl_type_com'), 'repl_type_completor/version'
assert_equal ['repl_type_completor/version'], ReplTypeCompletor::RequirePaths.require_completions('repl_type_completor/vers')
assert_equal 1, ReplTypeCompletor::RequirePaths.require_completions('ir').tally['irb']
end

def test_require_relative_paths
Expand Down

0 comments on commit ec66984

Please sign in to comment.