Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure top level scripts are indexed #2849

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/ruby_indexer/lib/ruby_indexer/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ def indexables

indexables = T.let([], T::Array[IndexablePath])

# Handle top level files separately. The path below is an optimization to prevent descending down directories that
# are going to be excluded anyway, so we need to handle top level scripts separately
Dir.glob(File.join(@workspace_path, "*.rb"), flags).each do |path|
indexables << IndexablePath.new(nil, path)
end

# Add user specified patterns
@included_patterns.each do |pattern|
load_path_entry = T.let(nil, T.nilable(String))
Expand Down
10 changes: 10 additions & 0 deletions lib/ruby_indexer/test/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,15 @@ def test_indexables_respect_given_workspace_path
)
end
end

def test_includes_top_level_files
Dir.mktmpdir do |dir|
FileUtils.touch(File.join(dir, "find_me.rb"))
@config.workspace_path = dir

indexables = @config.indexables
assert(indexables.find { |i| File.basename(i.full_path) == "find_me.rb" })
end
end
end
end
Loading