Skip to content

Commit e6a3703

Browse files
authored
Ensure top level scripts are indexed (#2849)
### Motivation With the optimizations to prevent descending into directories that we know are going to be excluded, we accidentally stopped indexing top level scripts. ### Implementation Since the code now lists directories to eagerly exclude them, we need a separate path for the top level scripts. ### Automated Tests Added a test that reproduces the issue.
1 parent 0eaaee1 commit e6a3703

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/ruby_indexer/lib/ruby_indexer/configuration.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ def indexables
109109

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

112+
# Handle top level files separately. The path below is an optimization to prevent descending down directories that
113+
# are going to be excluded anyway, so we need to handle top level scripts separately
114+
Dir.glob(File.join(@workspace_path, "*.rb"), flags).each do |path|
115+
indexables << IndexablePath.new(nil, path)
116+
end
117+
112118
# Add user specified patterns
113119
@included_patterns.each do |pattern|
114120
load_path_entry = T.let(nil, T.nilable(String))

lib/ruby_indexer/test/configuration_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,15 @@ def test_indexables_respect_given_workspace_path
160160
)
161161
end
162162
end
163+
164+
def test_includes_top_level_files
165+
Dir.mktmpdir do |dir|
166+
FileUtils.touch(File.join(dir, "find_me.rb"))
167+
@config.workspace_path = dir
168+
169+
indexables = @config.indexables
170+
assert(indexables.find { |i| File.basename(i.full_path) == "find_me.rb" })
171+
end
172+
end
163173
end
164174
end

0 commit comments

Comments
 (0)