Skip to content

Commit 9526b4c

Browse files
committed
exclude completions of binding pattern variable initializers
1 parent a0aea62 commit 9526b4c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/services/completions.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,8 +2123,14 @@ export function getCompletionEntriesFromSymbols(
21232123
}
21242124
// Filter out variables from their own initializers
21252125
// `const a = /* no 'a' here */`
2126-
if (tryCast(variableOrParameterDeclaration, isVariableDeclaration) && symbol.valueDeclaration === variableOrParameterDeclaration) {
2127-
return false;
2126+
if (variableOrParameterDeclaration && tryCast(variableOrParameterDeclaration, isVariableDeclaration)) {
2127+
if (symbol.valueDeclaration === variableOrParameterDeclaration) {
2128+
return false;
2129+
}
2130+
// const { a } = /* no 'a' here */;
2131+
if (isBindingPattern(variableOrParameterDeclaration.name) && variableOrParameterDeclaration.name.elements.some(e => e === symbol.valueDeclaration)) {
2132+
return false;
2133+
}
21282134
}
21292135

21302136
// Filter out parameters from their own initializers

0 commit comments

Comments
 (0)