Don't treat class name as a completion list blocker if the position comes after it (#20762)

This commit is contained in:
Andy
2017-12-18 12:41:05 -08:00
committed by GitHub
parent 1562a278f8
commit 60bd262437
2 changed files with 15 additions and 1 deletions

View File

@@ -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) {

View File

@@ -0,0 +1,11 @@
/// <reference path="fourslash.ts" />
////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");