Skip to content

Commit bfc17fe

Browse files
authored
Apply suggestion from @jakebailey
1 parent cdeaa0b commit bfc17fe

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/ls/definition.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ func (l *LanguageService) createLocationFromFileAndRange(file *ast.SourceFile, t
171171

172172
func getDeclarationsFromLocation(c *checker.Checker, node *ast.Node) []*ast.Node {
173173
if ast.IsIdentifier(node) && ast.IsShorthandPropertyAssignment(node.Parent) {
174-
// For shorthand property assignments, return both the value symbol's declarations
174+
// Because name in short-hand property assignment has two different meanings: property name and property value,
175+
// using go-to-definition at such position should go to the variable declaration of the property value rather than
176+
// go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition
177+
// is performed at the location of property access, we would like to go to definition of the property in the short-hand
178+
// assignment. This case and others are handled by the following code.
175179
// and the contextual type's property declarations
176180
shorthandSymbol := c.GetResolvedSymbol(node)
177181
var declarations []*ast.Node

0 commit comments

Comments
 (0)