File tree Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -785,13 +785,7 @@ export default class Analyzer {
785
785
}
786
786
}
787
787
788
- if (
789
- node . type === 'word' &&
790
- node . parent ?. type === 'command' &&
791
- node . parent . firstChild ?. text === 'read' &&
792
- ! node . text . startsWith ( '-' ) &&
793
- ! / ^ - .* [ d i n N p t u ] $ / . test ( node . previousSibling ?. text ?? '' )
794
- ) {
788
+ if ( TreeSitterUtil . isVariableInReadCommand ( node ) ) {
795
789
return {
796
790
word : node . text ,
797
791
range : TreeSitterUtil . range ( node ) ,
Original file line number Diff line number Diff line change @@ -361,6 +361,16 @@ export function findDeclarationUsingGlobalSemantics({
361
361
return true
362
362
}
363
363
364
+ if (
365
+ kind === LSP . SymbolKind . Variable &&
366
+ TreeSitterUtil . isVariableInReadCommand ( n ) &&
367
+ n . text === word
368
+ ) {
369
+ declaration = n
370
+ continueSearching = false
371
+ return false
372
+ }
373
+
364
374
if (
365
375
kind === LSP . SymbolKind . Function &&
366
376
n . type === 'function_definition' &&
Original file line number Diff line number Diff line change @@ -43,6 +43,20 @@ export function isReference(n: SyntaxNode): boolean {
43
43
}
44
44
}
45
45
46
+ export function isVariableInReadCommand ( n : SyntaxNode ) : boolean {
47
+ if (
48
+ n . type === 'word' &&
49
+ n . parent ?. type === 'command' &&
50
+ n . parent . firstChild ?. text === 'read' &&
51
+ ! n . text . startsWith ( '-' ) &&
52
+ ! / ^ - .* [ d i n N p t u ] $ / . test ( n . previousSibling ?. text ?? '' )
53
+ ) {
54
+ return true
55
+ }
56
+
57
+ return false
58
+ }
59
+
46
60
export function findParent (
47
61
start : SyntaxNode ,
48
62
predicate : ( n : SyntaxNode ) => boolean ,
You can’t perform that action at this time.
0 commit comments