From 27b29cda6a0544e19ce9e42bbd44701468b34baa Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 12 Jan 2022 13:24:12 -0800 Subject: [PATCH] Revert "Cherry-pick PR #47096 into release-4.5 (#47105)" This reverts commit 1d4ec40130bae10f4b955bd7672054e34cba8caa. --- src/services/completions.ts | 19 +----- .../jsxAttributeAsTagNameNoSnippet.ts | 61 ------------------- 2 files changed, 1 insertion(+), 79 deletions(-) delete mode 100644 tests/cases/fourslash/jsxAttributeAsTagNameNoSnippet.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index b0b7075191462..9961a699945f7 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -713,25 +713,8 @@ namespace ts.Completions { } } - // Before offering up a JSX attribute snippet, ensure that we aren't potentially completing - // a tag name; this may appear as an attribute after the "<" when the tag has not yet been - // closed, as in: - // - // return <> - // foo - // - // We can detect this case by checking if both: - // - // 1. The location is "<", so we are completing immediately after it. - // 2. The "<" has the same position as its parent, so is not a binary expression. const kind = SymbolDisplay.getSymbolKind(typeChecker, symbol, location); - if ( - kind === ScriptElementKind.jsxAttribute - && (location.kind !== SyntaxKind.LessThanToken || location.pos !== location.parent.pos) - && preferences.includeCompletionsWithSnippetText - && preferences.jsxAttributeCompletionStyle - && preferences.jsxAttributeCompletionStyle !== "none") { + if (kind === ScriptElementKind.jsxAttribute && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") { let useBraces = preferences.jsxAttributeCompletionStyle === "braces"; const type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); diff --git a/tests/cases/fourslash/jsxAttributeAsTagNameNoSnippet.ts b/tests/cases/fourslash/jsxAttributeAsTagNameNoSnippet.ts deleted file mode 100644 index 40766cf294619..0000000000000 --- a/tests/cases/fourslash/jsxAttributeAsTagNameNoSnippet.ts +++ /dev/null @@ -1,61 +0,0 @@ -/// -//@Filename: file.tsx -////declare namespace JSX { -//// interface IntrinsicElements { -//// button: any; -//// div: any; -//// } -////} -////function fn() { -//// return <> -//// ; -////} -////function fn2() { -//// return <> -//// preceding junk ; -////} -////function fn3() { -//// return <> -//// ; -////} - - - -verify.completions( - { - marker: "1", - includes: [ - { name: "button", insertText: undefined, isSnippet: undefined } - ], - preferences: { - jsxAttributeCompletionStyle: "braces", - includeCompletionsWithSnippetText: true, - includeCompletionsWithInsertText: true, - } - }, - { - marker: "2", - includes: [ - { name: "button", insertText: undefined, isSnippet: undefined } - ], - preferences: { - jsxAttributeCompletionStyle: "braces", - includeCompletionsWithSnippetText: true, - includeCompletionsWithInsertText: true, - } - }, - { - marker: "3", - includes: [ - { name: "button", insertText: undefined, isSnippet: undefined } - ], - preferences: { - jsxAttributeCompletionStyle: "braces", - includeCompletionsWithSnippetText: true, - includeCompletionsWithInsertText: true, - } - }, -);