Skip to content

Commit 3dff0af

Browse files
committed
fix critical mistake thx to tests
1 parent e972f32 commit 3dff0af

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

typescript/src/completions/jsxAttributes.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,8 @@ export default (
3737
jsxAttributeCandidate = true
3838
node = node.parent
3939
}
40-
if (jsxAttributeCandidate) {
41-
if (
42-
sharedCompletionContext.c('improveJsxCompletions') &&
43-
Object.keys(jsxCompletionsMap).length > 0 &&
44-
(ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node))
45-
) {
40+
if (jsxAttributeCandidate && (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node))) {
41+
if (sharedCompletionContext.c('improveJsxCompletions') && Object.keys(jsxCompletionsMap).length > 0) {
4642
const tagName = node.tagName.getText()
4743
// TODO use the same perf optimization for replaceSuggestions
4844
const patchEntries: Record<number, Configuration['jsxCompletionsMap'][string]> = {}

typescript/test/completions.spec.ts

+18
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ test('Case-sensetive completions', () => {
499499
test('Fix properties sorting', () => {
500500
overrideSettings({
501501
fixSuggestionsSorting: true,
502+
'jsxAttributeShortcutCompletions.enable': 'disable',
502503
})
503504
fourslashLikeTester(/* tsx */ `
504505
let a: {
@@ -613,6 +614,23 @@ test('Tuple signature', () => {
613614
})
614615
})
615616

617+
test('JSX attribute shortcut completions', () => {
618+
const tester = fourslashLikeTester(/* tsx */ `
619+
const A = ({a, b}) => {}
620+
const a = 5
621+
const c = <A /*1*/ />
622+
const d = <A a={/*2*/} />
623+
`)
624+
tester.completion(1, {
625+
exact: {
626+
names: ['a', 'a={a}', 'b'],
627+
},
628+
})
629+
tester.completion(2, {
630+
excludes: ['a={a}'],
631+
})
632+
})
633+
616634
test('Object Literal Completions', () => {
617635
const [_positivePositions, _negativePositions, numPositions] = fileContentsSpecialPositions(/* ts */ `
618636
interface Options {

0 commit comments

Comments
 (0)