From e9ba29c69b02e1fb101228722dbbb8f04127ec2a Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 1 Feb 2018 10:01:02 -0800 Subject: [PATCH] Don't treat class name contextToken as a completion list blocker if it is not the previousToken (#21534) (#21536) --- src/services/completions.ts | 3 ++- tests/cases/fourslash/completionsKeywordsExtends.ts | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index bce1eadaf26..60dfa8aaaa2 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1921,7 +1921,8 @@ namespace ts.Completions { return isDeclarationName(contextToken) && !isJsxAttribute(contextToken.parent) // Don't block completions if we're in `class C /**/`, because we're *past* the end of the identifier and might want to complete `extends`. - && !(isClassLike(contextToken.parent) && position > previousToken.end); + // If `contextToken !== previousToken`, this is `class C ex/**/`. + && !(isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind: SyntaxKind) { diff --git a/tests/cases/fourslash/completionsKeywordsExtends.ts b/tests/cases/fourslash/completionsKeywordsExtends.ts index 065d30d1286..50c9b741cda 100644 --- a/tests/cases/fourslash/completionsKeywordsExtends.ts +++ b/tests/cases/fourslash/completionsKeywordsExtends.ts @@ -1,6 +1,7 @@ /// ////class C/*a*/ /*b*/ { } +////class C e/*c*/ {} // Tests that `isCompletionListBlocker` is true *at* the class name, but false *after* it. @@ -9,3 +10,6 @@ verify.completionListIsEmpty(); goTo.marker("b"); verify.completionListContains("extends"); + +goTo.marker("c"); +verify.completionListContains("extends");