From dba03377b816123149046030b869baa70ae35291 Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Tue, 18 Oct 2016 14:04:21 -0700 Subject: [PATCH] Adding JSXExpression check for isGlobalCompletion and associated tests --- src/services/completions.ts | 1 + .../fourslash/completionListIsGlobalCompletion.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index cd4d64b3b09..3b76fdc8c3b 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1082,6 +1082,7 @@ namespace ts.Completions { isGlobalCompletion = scopeNode.kind === SyntaxKind.SourceFile || scopeNode.kind === SyntaxKind.TemplateExpression || + scopeNode.kind === SyntaxKind.JsxExpression || isStatement(scopeNode); } diff --git a/tests/cases/fourslash/completionListIsGlobalCompletion.ts b/tests/cases/fourslash/completionListIsGlobalCompletion.ts index 3961f4fadae..a1fadc6bb12 100644 --- a/tests/cases/fourslash/completionListIsGlobalCompletion.ts +++ b/tests/cases/fourslash/completionListIsGlobalCompletion.ts @@ -33,6 +33,7 @@ ////const y =
; // no globals in jsx attribute found ////const z =
; // no globals in jsx attribute with syntax error ////const x = `/*14*/ ${/*15*/}`; // globals only in template expression +////var user = ; // globals only in JSX expression (but not in JSX expression strings) goTo.marker("1"); verify.completionListIsGlobal(false); goTo.marker("2"); @@ -62,4 +63,12 @@ verify.completionListIsGlobal(false); goTo.marker("14"); verify.completionListIsGlobal(false); goTo.marker("15"); -verify.completionListIsGlobal(true); \ No newline at end of file +verify.completionListIsGlobal(true); +goTo.marker("16"); +verify.completionListIsGlobal(false); +goTo.marker("17"); +verify.completionListIsGlobal(false); +goTo.marker("18"); +verify.completionListIsGlobal(true); +goTo.marker("19"); +verify.completionListIsGlobal(false); \ No newline at end of file