From 61f5ceb8322ada7e24ba4ac14491248eb7bd202e Mon Sep 17 00:00:00 2001 From: Adam Burgess Date: Mon, 25 Oct 2021 17:49:31 +1100 Subject: [PATCH] Fix isNewIdentifierLocation after generator (#46491) --- src/services/completions.ts | 3 ++ .../completionsGeneratorMethodDeclaration.ts | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/cases/fourslash/completionsGeneratorMethodDeclaration.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index a30da4071c5..2f5f0323a9a 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -2258,6 +2258,9 @@ namespace ts.Completions { case SyntaxKind.AsyncKeyword: return containingNodeKind === SyntaxKind.MethodDeclaration // const obj = { async c|() || containingNodeKind === SyntaxKind.ShorthandPropertyAssignment; // const obj = { async c| + + case SyntaxKind.AsteriskToken: + return containingNodeKind === SyntaxKind.MethodDeclaration; // const obj = { * c| } if (isClassMemberCompletionKeyword(tokenKind)) { diff --git a/tests/cases/fourslash/completionsGeneratorMethodDeclaration.ts b/tests/cases/fourslash/completionsGeneratorMethodDeclaration.ts new file mode 100644 index 00000000000..d4c6ad99e8e --- /dev/null +++ b/tests/cases/fourslash/completionsGeneratorMethodDeclaration.ts @@ -0,0 +1,28 @@ +/// + +//// const obj = { +//// a() {}, +//// * b/*1*/ +//// }; +//// const obj2 = { +//// * /*2*/ +//// }; +//// const obj3 = { +//// async * /*3*/ +//// }; +//// class Foo { +//// * b/*4*/ +//// } +//// class Foo2 { +//// * /*5*/ +//// } +//// class Bar { +//// static * b/*6*/ +//// } + +test.markerNames().forEach(marker => { + verify.completions({ + marker, + isNewIdentifierLocation: true + }); +});