diff --git a/typescript/src/completions/jsxAttributes.ts b/typescript/src/completions/jsxAttributes.ts index 727366b..976b821 100644 --- a/typescript/src/completions/jsxAttributes.ts +++ b/typescript/src/completions/jsxAttributes.ts @@ -37,12 +37,8 @@ export default ( jsxAttributeCandidate = true node = node.parent } - if (jsxAttributeCandidate) { - if ( - sharedCompletionContext.c('improveJsxCompletions') && - Object.keys(jsxCompletionsMap).length > 0 && - (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) - ) { + if (jsxAttributeCandidate && (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node))) { + if (sharedCompletionContext.c('improveJsxCompletions') && Object.keys(jsxCompletionsMap).length > 0) { const tagName = node.tagName.getText() // TODO use the same perf optimization for replaceSuggestions const patchEntries: Record = {} diff --git a/typescript/test/completions.spec.ts b/typescript/test/completions.spec.ts index 04b6a6d..6abcd2b 100644 --- a/typescript/test/completions.spec.ts +++ b/typescript/test/completions.spec.ts @@ -499,6 +499,7 @@ test('Case-sensetive completions', () => { test('Fix properties sorting', () => { overrideSettings({ fixSuggestionsSorting: true, + 'jsxAttributeShortcutCompletions.enable': 'disable', }) fourslashLikeTester(/* tsx */ ` let a: { @@ -613,6 +614,23 @@ test('Tuple signature', () => { }) }) +test('JSX attribute shortcut completions', () => { + const tester = fourslashLikeTester(/* tsx */ ` + const A = ({a, b}) => {} + const a = 5 + const c = + const d = + `) + tester.completion(1, { + exact: { + names: ['a', 'a={a}', 'b'], + }, + }) + tester.completion(2, { + excludes: ['a={a}'], + }) +}) + test('Object Literal Completions', () => { const [_positivePositions, _negativePositions, numPositions] = fileContentsSpecialPositions(/* ts */ ` interface Options {