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