Skip to content

Commit f23c6e6

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

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

server/src/server.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,8 +1225,11 @@ 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+
// For normal declarations, the id is nested inside a pattern
1230+
if (node.type === "declaration") bindingNode = bindingNode?.child(0);
1231+
1232+
if (!bindingNode) {
12301233
return {
12311234
name: "unknown",
12321235
kind: SymbolKind.Variable,
@@ -1237,7 +1240,7 @@ function createDocumentSymbol(
12371240
};
12381241
}
12391242

1240-
const name = getSymbolName(patternNode, document);
1243+
const name = getSymbolName(bindingNode, document);
12411244
const exprNode = node.namedChild(node.namedChildCount - 1);
12421245
const kind = getSymbolKind(exprNode);
12431246
const detail = getSymbolDetail(node, exprNode);
@@ -1246,7 +1249,7 @@ function createDocumentSymbol(
12461249
name,
12471250
kind,
12481251
range: nodeToRange(node),
1249-
selectionRange: nodeToRange(patternNode),
1252+
selectionRange: nodeToRange(bindingNode),
12501253
detail,
12511254
children: [],
12521255
};

0 commit comments

Comments
 (0)