Skip to content

Commit 1f32fef

Browse files
authored
fix(51077): skip insertText for jsx attribute with existing initializer (#51093)
1 parent f3d55db commit 1f32fef

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/services/completions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,9 @@ function createCompletionEntry(
13921392
sortText = SortText.SortBelow(sortText);
13931393
}
13941394

1395-
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
1395+
if (isJsxIdentifierExpected && !isRightOfOpenTag
1396+
&& preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle
1397+
&& preferences.jsxAttributeCompletionStyle !== "none" && !(isJsxAttribute(location.parent) && location.parent.initializer)) {
13961398
let useBraces = preferences.jsxAttributeCompletionStyle === "braces";
13971399
const type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
13981400

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @filename: /foo.tsx
4+
////declare namespace JSX {
5+
//// interface Element { }
6+
//// interface IntrinsicElements {
7+
//// foo: {
8+
//// className: string;
9+
//// }
10+
//// }
11+
////}
12+
////<foo cl/**/={""} />
13+
14+
verify.completions({
15+
marker: "",
16+
includes: {
17+
name: "className",
18+
text: "(property) className: string",
19+
insertText: undefined,
20+
isSnippet: undefined,
21+
},
22+
preferences: {
23+
jsxAttributeCompletionStyle: "braces",
24+
includeCompletionsWithSnippetText: true,
25+
includeCompletionsWithInsertText: true,
26+
},
27+
})

0 commit comments

Comments
 (0)