File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -1225,8 +1225,11 @@ function createDocumentSymbol(
1225
1225
node : SyntaxNode ,
1226
1226
document : TextDocument ,
1227
1227
) : 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 ) {
1230
1233
return {
1231
1234
name : "unknown" ,
1232
1235
kind : SymbolKind . Variable ,
@@ -1237,7 +1240,7 @@ function createDocumentSymbol(
1237
1240
} ;
1238
1241
}
1239
1242
1240
- const name = getSymbolName ( patternNode , document ) ;
1243
+ const name = getSymbolName ( bindingNode , document ) ;
1241
1244
const exprNode = node . namedChild ( node . namedChildCount - 1 ) ;
1242
1245
const kind = getSymbolKind ( exprNode ) ;
1243
1246
const detail = getSymbolDetail ( node , exprNode ) ;
@@ -1246,7 +1249,7 @@ function createDocumentSymbol(
1246
1249
name,
1247
1250
kind,
1248
1251
range : nodeToRange ( node ) ,
1249
- selectionRange : nodeToRange ( patternNode ) ,
1252
+ selectionRange : nodeToRange ( bindingNode ) ,
1250
1253
detail,
1251
1254
children : [ ] ,
1252
1255
} ;
You can’t perform that action at this time.
0 commit comments