From c4dfd07a0537041556d7c074ebea60987ffc3d2b Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Mon, 9 Jun 2025 08:10:48 -0400 Subject: Fix goto definition taking you to the field definition instead of the variable declaration when used with a selector expr --- src/server/definition.odin | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'src/server') diff --git a/src/server/definition.odin b/src/server/definition.odin index 0a216cc..00a62fc 100644 --- a/src/server/definition.odin +++ b/src/server/definition.odin @@ -76,25 +76,22 @@ get_definition_location :: proc(document: ^Document, position: common.Position) } } else if position_context.selector_expr != nil { //if the base selector is the client wants to go to. - if base, ok := position_context.selector.derived.(^ast.Ident); ok && position_context.identifier != nil { + if position_in_node(position_context.selector, position_context.position) && position_context.identifier != nil { ident := position_context.identifier.derived.(^ast.Ident) + if resolved, ok := resolve_location_identifier(&ast_context, ident^); ok { + location.range = resolved.range - if position_in_node(base, position_context.position) { - if resolved, ok := resolve_location_identifier(&ast_context, ident^); ok { - location.range = resolved.range - - if resolved.uri == "" { - location.uri = document.uri.uri - } else { - location.uri = resolved.uri - } - - append(&locations, location) - - return locations[:], true + if resolved.uri == "" { + location.uri = document.uri.uri } else { - return {}, false + location.uri = resolved.uri } + + append(&locations, location) + + return locations[:], true + } else { + return {}, false } } -- cgit v1.2.3