@@ -466,15 +466,18 @@ export default class Analyzer {
466
466
467
467
const typeOfDescendants =
468
468
kind === LSP . SymbolKind . Variable
469
- ? 'variable_name'
469
+ ? [ 'variable_name' , 'word' ]
470
470
: [ 'function_definition' , 'command_name' ]
471
471
const startPosition = start
472
472
? { row : start . line , column : start . character }
473
473
: baseNode . startPosition
474
474
475
475
const ignoredRanges : LSP . Range [ ] = [ ]
476
476
const filterVariables = ( n : Parser . SyntaxNode ) => {
477
- if ( n . text !== word ) {
477
+ if (
478
+ n . text !== word ||
479
+ ( n . type === 'word' && ! TreeSitterUtil . isVariableInReadCommand ( n ) )
480
+ ) {
478
481
return false
479
482
}
480
483
@@ -510,11 +513,14 @@ export default class Analyzer {
510
513
511
514
const declarationCommand = TreeSitterUtil . findParentOfType ( n , 'declaration_command' )
512
515
const isLocal =
513
- ( definedVariable ?. text === word || ! ! ( ! definition && declarationCommand ) ) &&
514
- ( parent . type === 'subshell' ||
515
- [ 'local' , 'declare' , 'typeset' ] . includes (
516
- declarationCommand ?. firstChild ?. text as any ,
517
- ) )
516
+ // Local `variable_name`s
517
+ ( ( definedVariable ?. text === word || ! ! ( ! definition && declarationCommand ) ) &&
518
+ ( parent . type === 'subshell' ||
519
+ [ 'local' , 'declare' , 'typeset' ] . includes (
520
+ declarationCommand ?. firstChild ?. text as any ,
521
+ ) ) ) ||
522
+ // Local variables within `read` command that are typed as `word`
523
+ ( parent . type === 'subshell' && n . type === 'word' )
518
524
if ( isLocal ) {
519
525
if ( includeDeclaration ) {
520
526
ignoredRanges . push ( TreeSitterUtil . range ( parent ) )
0 commit comments