aboutsummaryrefslogtreecommitdiff
path: root/src/server/definition.odin
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-06-09 08:10:48 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-06-09 10:14:13 -0400
commitc4dfd07a0537041556d7c074ebea60987ffc3d2b (patch)
tree9ecee74df9a13751fc7ba382ac8d79da017030b0 /src/server/definition.odin
parenta42400e0c9f1471ec27454476f6fe6c19dc95242 (diff)
Fix goto definition taking you to the field definition instead of the variable declaration when used with a selector expr
Diffstat (limited to 'src/server/definition.odin')
-rw-r--r--src/server/definition.odin27
1 files changed, 12 insertions, 15 deletions
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
}
}