Skip to content

Commit 2a6591e

Browse files
authored
Merge pull request #764 from Shopify/vs/do_not_break_for_empty_gem_statements
Prevent breaking on empty gem statements
2 parents f316582 + 7edbe65 commit 2a6591e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/ruby_lsp/requests/code_lens.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,10 @@ def add_test_code_lens(node, name:, command:, kind:)
193193

194194
sig { params(node: SyntaxTree::Command).returns(T.nilable(String)) }
195195
def resolve_gem_remote(node)
196-
gem_name = node.arguments.parts.flat_map(&:child_nodes).first.value
197-
spec = Gem::Specification.stubs.find { |gem| gem.name == gem_name }&.to_spec
196+
gem_statement = node.arguments.parts.flat_map(&:child_nodes).first
197+
return unless gem_statement
198+
199+
spec = Gem::Specification.stubs.find { |gem| gem.name == gem_statement.value }&.to_spec
198200
return if spec.nil?
199201

200202
[spec.homepage, spec.metadata["source_code_uri"]].compact.find do |page|

test/fixtures/Gemfile.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
group :development do
66
gem "debug", "~> 1.7", require: false
77
end
8+
9+
# Make sure we don't break as the user is typing
10+
gem ""

0 commit comments

Comments
 (0)