diff --git a/src/services/completions.ts b/src/services/completions.ts index a09aebcb7d1..68ed11c1c26 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -866,6 +866,7 @@ function completionInfoFromData( isTypeOnlyLocation, isJsxIdentifierExpected, isRightOfOpenTag, + isRightOfDotOrQuestionDot, importStatementCompletion, insideJsDocTagTypeExpression, symbolToSortTextMap: symbolToSortTextMap, @@ -941,6 +942,8 @@ function completionInfoFromData( let caseBlock: CaseBlock | undefined; if (preferences.includeCompletionsWithInsertText && contextToken + && !isRightOfOpenTag + && !isRightOfDotOrQuestionDot && (caseBlock = findAncestor(contextToken, isCaseBlock))) { const cases = getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, compilerOptions, host, program, formatContext); if (cases) { @@ -2524,6 +2527,7 @@ interface CompletionData { /** In JSX tag name and attribute names, identifiers like "my-tag" or "aria-name" is valid identifier. */ readonly isJsxIdentifierExpected: boolean; readonly isRightOfOpenTag: boolean; + readonly isRightOfDotOrQuestionDot: boolean; readonly importStatementCompletion?: ImportStatementCompletionInfo; readonly hasUnresolvedAutoImports?: boolean; readonly flags: CompletionInfoFlags; @@ -2940,6 +2944,7 @@ function getCompletionData( isTypeOnlyLocation, isJsxIdentifierExpected, isRightOfOpenTag, + isRightOfDotOrQuestionDot: isRightOfDot || isRightOfQuestionDot, importStatementCompletion, hasUnresolvedAutoImports, flags, diff --git a/tests/cases/fourslash/exhaustiveCaseCompletions3.ts b/tests/cases/fourslash/exhaustiveCaseCompletions3.ts index 248acab7e17..f93e1767738 100644 --- a/tests/cases/fourslash/exhaustiveCaseCompletions3.ts +++ b/tests/cases/fourslash/exhaustiveCaseCompletions3.ts @@ -30,6 +30,9 @@ //// switch (u) { //// /*7*/ //// +//// switch (u) { +//// case E./*8*/ +//// } const exhaustiveCaseCompletion = { name: "case E.A: ...", @@ -109,4 +112,15 @@ verify.completions( includeCompletionsWithInsertText: true, } }, + { + marker: "8", + exact: [ + "A", + "B", + "C" + ], + preferences: { + includeCompletionsWithInsertText: true, + } + }, ); \ No newline at end of file