Skip to content
Open
2 changes: 1 addition & 1 deletion internal/ls/completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2753,7 +2753,7 @@ func getSourceFromOrigin(origin *symbolOriginInfo) string {
func getRelevantTokens(position int, file *ast.SourceFile) (contextToken *ast.Node, previousToken *ast.Node) {
previousToken = astnav.FindPrecedingToken(file, position)
if previousToken != nil && position <= previousToken.End() && (ast.IsMemberName(previousToken) || ast.IsKeywordKind(previousToken.Kind)) {
contextToken := astnav.FindPrecedingToken(file, previousToken.Pos())
contextToken = astnav.FindPrecedingToken(file, previousToken.Pos())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can't possibly do anything anymore...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right - the variable shadowing fix alone wasn't sufficient. The issue was that tryGetObjectTypeDeclarationCompletionContainer could return a non-nil declaration even when contextToken was nil (specifically in the Identifier case at line 4166). I've added a nil check there: if contextToken != nil && isFromObjectTypeDeclaration(location) (commit 27b3371).

return contextToken, previousToken
}
return previousToken, previousToken
Expand Down