File tree 2 files changed +20
-6
lines changed
2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -37,12 +37,8 @@ export default (
37
37
jsxAttributeCandidate = true
38
38
node = node . parent
39
39
}
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 ) {
46
42
const tagName = node . tagName . getText ( )
47
43
// TODO use the same perf optimization for replaceSuggestions
48
44
const patchEntries : Record < number , Configuration [ 'jsxCompletionsMap' ] [ string ] > = { }
Original file line number Diff line number Diff line change @@ -499,6 +499,7 @@ test('Case-sensetive completions', () => {
499
499
test ( 'Fix properties sorting' , ( ) => {
500
500
overrideSettings ( {
501
501
fixSuggestionsSorting : true ,
502
+ 'jsxAttributeShortcutCompletions.enable' : 'disable' ,
502
503
} )
503
504
fourslashLikeTester ( /* tsx */ `
504
505
let a: {
@@ -613,6 +614,23 @@ test('Tuple signature', () => {
613
614
} )
614
615
} )
615
616
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
+
616
634
test ( 'Object Literal Completions' , ( ) => {
617
635
const [ _positivePositions , _negativePositions , numPositions ] = fileContentsSpecialPositions ( /* ts */ `
618
636
interface Options {
You can’t perform that action at this time.
0 commit comments