diff --git a/lib/steep/services/goto_service.rb b/lib/steep/services/goto_service.rb index 5a2adb820..89dea6315 100644 --- a/lib/steep/services/goto_service.rb +++ b/lib/steep/services/goto_service.rb @@ -111,6 +111,7 @@ def query_at(path:, line:, column:) typing, signature = type_check_path(target: target, path: relative_path, content: source.content, line: line, column: column) if typing node, *parents = typing.source.find_nodes(line: line, column: column) + if node case node.type when :const, :casgn @@ -136,7 +137,10 @@ def query_at(path:, line:, column:) end when :send if test_ast_location(node.location.selector, line: line, column: column) - node = parents[0] if parents[0]&.type == :block + if (parent = parents[0]) && parent.type == :block && parent.children[0] == node + node = parents[0] + end + case call = typing.call_of(node: node) when TypeInference::MethodCall::Typed, TypeInference::MethodCall::Error call.method_decls.each do |decl| diff --git a/test/goto_service_test.rb b/test/goto_service_test.rb index 65d68ba81..3c63fa0c3 100644 --- a/test/goto_service_test.rb +++ b/test/goto_service_test.rb @@ -652,6 +652,24 @@ def test_method_block end end + def test_method_block_inner + type_check = type_check_service do |changes| + changes[Pathname("lib/test.rb")] = [ContentChange.string(<