lib/ruby_indexer/lib/ruby_indexer/configuration.rb in ruby-lsp-0.12.3 vs lib/ruby_indexer/lib/ruby_indexer/configuration.rb in ruby-lsp-0.12.4
- old
+ new
@@ -69,12 +69,17 @@
indexables = @included_patterns.flat_map do |pattern|
load_path_entry = T.let(nil, T.nilable(String))
Dir.glob(pattern, File::FNM_PATHNAME | File::FNM_EXTGLOB).map! do |path|
# All entries for the same pattern match the same $LOAD_PATH entry. Since searching the $LOAD_PATH for every
- # entry is expensive, we memoize it for the entire pattern
- load_path_entry ||= $LOAD_PATH.find { |load_path| path.start_with?(load_path) }
+ # entry is expensive, we memoize it until we find a path that doesn't belong to that $LOAD_PATH. This happens
+ # on repositories that define multiple gems, like Rails. All frameworks are defined inside the Dir.pwd, but
+ # each one of them belongs to a different $LOAD_PATH entry
+ if load_path_entry.nil? || !path.start_with?(load_path_entry)
+ load_path_entry = $LOAD_PATH.find { |load_path| path.start_with?(load_path) }
+ end
+
IndexablePath.new(load_path_entry, path)
end
end
# Remove user specified patterns
@@ -142,10 +147,10 @@
# If a gem is scoped only to some specific platform, then its dependencies may not be installed either, but they
# are still listed in locked_gems. We can't index them because they are not installed for the platform, so we
# just ignore if they're missing
end
- indexables.uniq!
+ indexables.uniq!(&:full_path)
indexables
end
sig { returns(Regexp) }
def magic_comment_regex