From 2ab41c16a4427ee355c55111c0e6eaf7d512cc0e Mon Sep 17 00:00:00 2001 From: Fred Snyder Date: Mon, 20 Nov 2023 06:19:54 -0500 Subject: [PATCH] YardMap ignores absolute paths (#678) --- lib/solargraph/yard_map.rb | 4 ++-- spec/yard_map_spec.rb | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/yard_map.rb b/lib/solargraph/yard_map.rb index 3b33c333b..89208a2bb 100755 --- a/lib/solargraph/yard_map.rb +++ b/lib/solargraph/yard_map.rb @@ -219,7 +219,7 @@ def process_gemsets def pins_for_require r, already_errored result = [] begin - name = r.split('/').first + name = r.split('/').first.to_s return [] if name.empty? || @source_gems.include?(name) || @gem_paths.key?(name) spec = spec_for_require(name) @gem_paths[name] = spec.full_gem_path @@ -282,7 +282,7 @@ def yardoc_file_for_spec spec # @param path [String] # @return [Gem::Specification] def spec_for_require path - name = path.split('/').first + name = path.split('/').first.to_s spec = Gem::Specification.find_by_name(name, @gemset[name]) # Avoid loading the spec again if it's going to be skipped anyway diff --git a/spec/yard_map_spec.rb b/spec/yard_map_spec.rb index 8be56853f..077216e7c 100644 --- a/spec/yard_map_spec.rb +++ b/spec/yard_map_spec.rb @@ -133,4 +133,14 @@ expect(pin).to be end end + + it 'ignores workspace requires starting with `/`' do + yard_map = Solargraph::YardMap.new + yard_map.change(['/'].to_set, "", [].to_set) + end + + it 'ignores require references starting with `/`' do + yard_map = Solargraph::YardMap.new + yard_map.require_reference('/') + end end