Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion internal/api/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,13 @@ func (s *Session) resolveNodeHandle(program *compiler.Program, handle Handle[ast
}

// Verify the kind and end match
if node.Kind != kind || node.End() != end {
if node.Kind != kind || node.Pos() != pos || node.End() != end {
// Try to find the exact node by walking ancestors
for parent := node.Parent; parent != nil && parent.Kind != ast.KindSourceFile; parent = parent.Parent {
if parent.Pos() == pos && parent.End() == end && parent.Kind == kind {
return parent, nil
}
}
// Try to find the exact node by walking children
var found *ast.Node
node.ForEachChild(func(child *ast.Node) bool {
Expand Down