Skip to content

Commit

Permalink
fix critical mistake thx to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Jan 17, 2024
1 parent e972f32 commit 3dff0af
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
8 changes: 2 additions & 6 deletions typescript/src/completions/jsxAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number, Configuration['jsxCompletionsMap'][string]> = {}
Expand Down
18 changes: 18 additions & 0 deletions typescript/test/completions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ test('Case-sensetive completions', () => {
test('Fix properties sorting', () => {
overrideSettings({
fixSuggestionsSorting: true,
'jsxAttributeShortcutCompletions.enable': 'disable',
})
fourslashLikeTester(/* tsx */ `
let a: {
Expand Down Expand Up @@ -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 = <A /*1*/ />
const d = <A a={/*2*/} />
`)
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 {
Expand Down

0 comments on commit 3dff0af

Please sign in to comment.