Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b1fa9d0

Browse files
committed
Rename variables typed as word within read commands
1 parent 420417a commit b1fa9d0

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

‎server/src/analyser.ts‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -466,15 +466,18 @@ export default class Analyzer {
466466

467467
const typeOfDescendants =
468468
kind === LSP.SymbolKind.Variable
469-
? 'variable_name'
469+
? ['variable_name','word']
470470
: ['function_definition', 'command_name']
471471
const startPosition = start
472472
? { row: start.line, column: start.character }
473473
: baseNode.startPosition
474474

475475
const ignoredRanges: LSP.Range[] = []
476476
const filterVariables = (n: Parser.SyntaxNode) => {
477-
if (n.text !== word) {
477+
if (
478+
n.text !== word ||
479+
(n.type === 'word' && !TreeSitterUtil.isVariableInReadCommand(n))
480+
) {
478481
return false
479482
}
480483

@@ -510,11 +513,14 @@ export default class Analyzer {
510513

511514
const declarationCommand = TreeSitterUtil.findParentOfType(n, 'declaration_command')
512515
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')
518524
if (isLocal) {
519525
if (includeDeclaration) {
520526
ignoredRanges.push(TreeSitterUtil.range(parent))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /