From 60bd2624370f057ffe3acb70eb8898569cbd94d2 Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 18 Dec 2017 12:41:05 -0800 Subject: [PATCH] Don't treat class name as a completion list blocker if the position comes after it (#20762) --- src/services/completions.ts | 5 ++++- tests/cases/fourslash/completionsKeywordsExtends.ts | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/completionsKeywordsExtends.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index 85095f65cef..a7020823d2e 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1760,7 +1760,10 @@ namespace ts.Completions { return true; } - return isDeclarationName(contextToken) && !isJsxAttribute(contextToken.parent); + 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); } function isFunctionLikeButNotConstructor(kind: SyntaxKind) { diff --git a/tests/cases/fourslash/completionsKeywordsExtends.ts b/tests/cases/fourslash/completionsKeywordsExtends.ts new file mode 100644 index 00000000000..065d30d1286 --- /dev/null +++ b/tests/cases/fourslash/completionsKeywordsExtends.ts @@ -0,0 +1,11 @@ +/// + +////class C/*a*/ /*b*/ { } + +// Tests that `isCompletionListBlocker` is true *at* the class name, but false *after* it. + +goTo.marker("a"); +verify.completionListIsEmpty(); + +goTo.marker("b"); +verify.completionListContains("extends");