Don't treat class name contextToken as a completion list blocker if it is not the previousToken (#21534) (#21536)

This commit is contained in:
Andy 2018-02-01 10:01:02 -08:00 committed by GitHub
parent 52df70b98c
commit e9ba29c69b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

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

View File

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