Skip to content

Commit c4c7a63

Browse files
committed
fix: don't expand method snippet in attributes name suggestions. Probably will be adopted instead in future
1 parent a257ef7 commit c4c7a63

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

typescript/src/completions/isGoodPositionMethodCompletion.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const isGoodPositionBuiltinMethodCompletion = (ts: typeof tslib, sourceFi
1515
if (ts.isJsxSelfClosingElement(currentNode) || ts.isJsxOpeningElement(currentNode)) return false
1616
if (ts.isShorthandPropertyAssignment(currentNode)) currentNode = currentNode.parent
1717
if (ts.isObjectBindingPattern(currentNode) || ts.isObjectLiteralExpression(currentNode)) return false
18+
if (ts.isJsxAttributes(currentNode) || ts.isJsxAttribute(currentNode)) return false
1819
if (c('disableMethodSnippets.jsxAttributes') && ts.isJsxExpression(currentNode)) return false
1920
}
2021
return true

typescript/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export = ({ typescript }: { typescript: typeof ts }) => {
8585
if (
8686
c('enableMethodSnippets') &&
8787
oneOf(
88-
prior.kind as string,
88+
prior.kind,
8989
ts.ScriptElementKind.constElement,
9090
ts.ScriptElementKind.letElement,
9191
ts.ScriptElementKind.alias,

typescript/test/completions.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ test('Builtin method snippet banned positions', () => {
6868
;<Test/*|*/></Test>
6969
;<Test test={/*|*/}></Test>
7070
;<Test test={a/*|*/}></Test>
71+
;<Test /*|*/></Test>
72+
;<Test a={5} /*|*/ b></Test>
73+
;<Test a/*|*/ />
7174
`)
7275
for (const [i, pos] of cursorPositions.entries()) {
7376
const result = isGoodPositionBuiltinMethodCompletion(ts, getSourceFile(), pos, defaultConfigFunc)
@@ -90,6 +93,9 @@ test('Additional banned positions for our method snippets', () => {
9093
;<Test/*|*/></Test>
9194
;<Test test={/*|*/}></Test>
9295
;<Test test={a/*|*/}></Test>
96+
;<Test /*|*/></Test>
97+
;<Test a={5} /*|*/ b></Test>
98+
;<Test a/*|*/ />
9399
`)
94100
for (const [i, pos] of cursorPositions.entries()) {
95101
const result = isGoodPositionMethodCompletion(ts, entrypoint, getSourceFile(), pos - 1, languageService, defaultConfigFunc)

0 commit comments

Comments
 (0)