From a04225dbecee5b90058441a33e772964ae89de26 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 25 Mar 2020 14:27:47 -0800 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20suppress=20completions=20after?= =?UTF-8?q?=20yield=20(#37609)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/completions.ts | 2 -- ...mpletionListInUnclosedYieldExpression01.ts | 3 +-- .../completionsImportYieldExpression.ts | 20 +++++++++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 tests/cases/fourslash/completionsImportYieldExpression.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index 478a9ece1c6..aeb19e3c78e 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -2159,7 +2159,6 @@ namespace ts.Completions { case SyntaxKind.ImportKeyword: case SyntaxKind.LetKeyword: case SyntaxKind.ConstKeyword: - case SyntaxKind.YieldKeyword: case SyntaxKind.TypeKeyword: // type htm| return true; @@ -2200,7 +2199,6 @@ namespace ts.Completions { case SyntaxKind.PublicKeyword: case SyntaxKind.StaticKeyword: case SyntaxKind.VarKeyword: - case SyntaxKind.YieldKeyword: return true; case SyntaxKind.AsyncKeyword: return isPropertyDeclaration(contextToken.parent); diff --git a/tests/cases/fourslash/completionListInUnclosedYieldExpression01.ts b/tests/cases/fourslash/completionListInUnclosedYieldExpression01.ts index 89b50e7bff5..998df73c1ce 100644 --- a/tests/cases/fourslash/completionListInUnclosedYieldExpression01.ts +++ b/tests/cases/fourslash/completionListInUnclosedYieldExpression01.ts @@ -3,5 +3,4 @@ ////var x; ////var y = function* gen(p) { yield /*1*/ -// These tentatively don't work. -verify.completions({ marker: "1", exact: undefined }); +verify.completions({ marker: "1", includes: ["x", "y", "gen", "p", ...completion.globalsVars] }); diff --git a/tests/cases/fourslash/completionsImportYieldExpression.ts b/tests/cases/fourslash/completionsImportYieldExpression.ts new file mode 100644 index 00000000000..e010154075e --- /dev/null +++ b/tests/cases/fourslash/completionsImportYieldExpression.ts @@ -0,0 +1,20 @@ +/// + +// @Filename: /a.ts +////export function a() {} + +// @Filename: /b.ts +////function *f() { +//// yield a/**/ +////} + +verify.applyCodeActionFromCompletion("", { + name: "a", + source: "/a", + description: `Import 'a' from module "./a"`, + newFileContent: `import { a } from "./a"; + +function *f() { + yield a +}` +});