diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt
index d20990edbd..14401cec42 100644
--- a/internal/fourslash/_scripts/failingTests.txt
+++ b/internal/fourslash/_scripts/failingTests.txt
@@ -129,7 +129,6 @@ TestCompletionsJSDocImportTagAttributesErrorModuleSpecifier1
TestCompletionsJSDocImportTagEmptyModuleSpecifier1
TestCompletionsJSDocNoCrash1
TestCompletionsJsdocTypeTagCast
-TestCompletionsJsxAttribute2
TestCompletionsJsxAttributeInitializer2
TestCompletionsLiteralFromInferenceWithinInferredType3
TestCompletionsLiterals
@@ -458,11 +457,8 @@ TestTripleSlashRefPathCompletionExtensionsAllowJSTrue
TestTripleSlashRefPathCompletionHiddenFile
TestTripleSlashRefPathCompletionRootdirs
TestTslibFindAllReferencesOnRuntimeImportWithPaths1
-TestTsxCompletion12
-TestTsxCompletion13
TestTsxCompletion14
TestTsxCompletion15
-TestTsxCompletion8
TestTsxCompletionNonTagLessThan
TestTsxQuickInfo1
TestTsxQuickInfo4
diff --git a/internal/fourslash/_scripts/manualTests.txt b/internal/fourslash/_scripts/manualTests.txt
index 492e3ccf70..9b8e2a61c4 100644
--- a/internal/fourslash/_scripts/manualTests.txt
+++ b/internal/fourslash/_scripts/manualTests.txt
@@ -2,3 +2,4 @@ completionListInClosedFunction05
completionsAtIncompleteObjectLiteralProperty
completionsSelfDeclaring1
completionsWithDeprecatedTag4
+tsxCompletion12
diff --git a/internal/fourslash/tests/gen/completionsJsxAttribute2_test.go b/internal/fourslash/tests/gen/completionsJsxAttribute2_test.go
index 4d1b9fe446..e5adc2a267 100644
--- a/internal/fourslash/tests/gen/completionsJsxAttribute2_test.go
+++ b/internal/fourslash/tests/gen/completionsJsxAttribute2_test.go
@@ -10,7 +10,7 @@ import (
func TestCompletionsJsxAttribute2(t *testing.T) {
t.Parallel()
- t.Skip()
+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `// @jsx: preserve
// @Filename: /a.tsx
diff --git a/internal/fourslash/tests/gen/tsxCompletion13_test.go b/internal/fourslash/tests/gen/tsxCompletion13_test.go
index 893708bfdf..d2aa047e6c 100644
--- a/internal/fourslash/tests/gen/tsxCompletion13_test.go
+++ b/internal/fourslash/tests/gen/tsxCompletion13_test.go
@@ -12,7 +12,7 @@ import (
func TestTsxCompletion13(t *testing.T) {
t.Parallel()
- t.Skip()
+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `//@Filename: file.tsx
// @jsx: preserve
diff --git a/internal/fourslash/tests/gen/tsxCompletion8_test.go b/internal/fourslash/tests/gen/tsxCompletion8_test.go
index 9dd5c3cfd5..9afbccbdea 100644
--- a/internal/fourslash/tests/gen/tsxCompletion8_test.go
+++ b/internal/fourslash/tests/gen/tsxCompletion8_test.go
@@ -10,7 +10,7 @@ import (
func TestTsxCompletion8(t *testing.T) {
t.Parallel()
- t.Skip()
+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `//@Filename: file.tsx
declare module JSX {
diff --git a/internal/fourslash/tests/gen/tsxCompletion12_test.go b/internal/fourslash/tests/manual/tsxCompletion12_test.go
similarity index 73%
rename from internal/fourslash/tests/gen/tsxCompletion12_test.go
rename to internal/fourslash/tests/manual/tsxCompletion12_test.go
index c2b9109784..959c261f2b 100644
--- a/internal/fourslash/tests/gen/tsxCompletion12_test.go
+++ b/internal/fourslash/tests/manual/tsxCompletion12_test.go
@@ -12,7 +12,7 @@ import (
func TestTsxCompletion12(t *testing.T) {
t.Parallel()
- t.Skip()
+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `//@Filename: file.tsx
// @jsx: preserve
@@ -30,12 +30,12 @@ func TestTsxCompletion12(t *testing.T) {
}
declare function Opt(attributes: OptionPropBag): JSX.Element;
let opt = ;
- let opt1 = ;
+ let opt1 = ;
let opt2 = ;
let opt3 = ;
let opt4 = ;`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
- f.VerifyCompletions(t, []string{"1", "2", "5"}, &fourslash.CompletionsExpectedList{
+ f.VerifyCompletions(t, []string{"1", "5"}, &fourslash.CompletionsExpectedList{
IsIncomplete: false,
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
CommitCharacters: &DefaultCommitCharacters,
@@ -55,6 +55,32 @@ func TestTsxCompletion12(t *testing.T) {
},
},
})
+ f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{
+ IsIncomplete: false,
+ ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
+ CommitCharacters: &DefaultCommitCharacters,
+ EditRange: Ignored,
+ },
+ Items: &fourslash.CompletionsExpectedItems{
+ Exact: []fourslash.CompletionsExpectedItem{
+ "propString",
+ "propx",
+ &lsproto.CompletionItem{
+ Label: "optional?",
+ FilterText: PtrTo("optional"),
+ Kind: PtrTo(lsproto.CompletionItemKindField),
+ SortText: PtrTo(string(ls.SortTextOptionalMember)),
+ TextEdit: &lsproto.TextEditOrInsertReplaceEdit{
+ InsertReplaceEdit: &lsproto.InsertReplaceEdit{
+ NewText: "optional",
+ Insert: f.Ranges()[0].LSRange,
+ Replace: f.Ranges()[0].LSRange,
+ },
+ },
+ },
+ },
+ },
+ })
f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{
IsIncomplete: false,
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
diff --git a/internal/ls/completions.go b/internal/ls/completions.go
index a7e249637d..ecb58dea14 100644
--- a/internal/ls/completions.go
+++ b/internal/ls/completions.go
@@ -4283,6 +4283,12 @@ func tryGetContainingJsxElement(contextToken *ast.Node, file *ast.SourceFile) *a
}
}
return parent
+ } else if parent != nil && parent.Kind == ast.KindJsxAttribute {
+ // Currently we parse JsxOpeningLikeElement as:
+ // JsxOpeningLikeElement
+ // attributes: JsxAttributes
+ // properties: NodeArray
+ return parent.Parent.Parent
}
// The context token is the closing } or " of an attribute, which means
// its parent is a JsxExpression, whose parent is a JsxAttribute,