Skip to content

Commit e2d2ed3

Browse files
committed
Fix test "should find all enhanced declarations"
1 parent 6343182 commit e2d2ed3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

server/src/server.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,8 +1225,12 @@ function createDocumentSymbol(
12251225
node: SyntaxNode,
12261226
document: TextDocument,
12271227
): DocumentSymbol {
1228-
const patternNode = node.child(0);
1229-
if (!patternNode) {
1228+
let bindingNode: SyntaxNode | null | undefined = node.child(0);
1229+
1230+
// For normal declarations, the id is nested inside a pattern
1231+
if (node.type === "declaration") bindingNode = bindingNode?.child(0);
1232+
1233+
if (!bindingNode) {
12301234
return {
12311235
name: "unknown",
12321236
kind: SymbolKind.Variable,
@@ -1237,7 +1241,7 @@ function createDocumentSymbol(
12371241
};
12381242
}
12391243

1240-
const name = getSymbolName(patternNode, document);
1244+
const name = getSymbolName(bindingNode, document);
12411245
const exprNode = node.namedChild(node.namedChildCount - 1);
12421246
const kind = getSymbolKind(exprNode);
12431247
const detail = getSymbolDetail(node, exprNode);
@@ -1246,7 +1250,7 @@ function createDocumentSymbol(
12461250
name,
12471251
kind,
12481252
range: nodeToRange(node),
1249-
selectionRange: nodeToRange(patternNode),
1253+
selectionRange: nodeToRange(bindingNode),
12501254
detail,
12511255
children: [],
12521256
};

0 commit comments

Comments
 (0)