Skip to content

Commit eab3711

Browse files
Merge pull request #11394 from RyanCavanaugh/noGlobalInJsxAttr
Don't show globals (e.g. snippets) in JSX positions
2 parents 7a67a3e + 3a0f3a2 commit eab3711

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/services/completions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,7 @@ namespace ts.Completions {
10011001
if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) {
10021002
// Cursor is inside a JSX self-closing element or opening element
10031003
attrsType = typeChecker.getJsxElementAttributesType(<JsxOpeningLikeElement>jsxContainer);
1004+
isGlobalCompletion = false;
10041005

10051006
if (attrsType) {
10061007
symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), (<JsxOpeningLikeElement>jsxContainer).attributes);

tests/cases/fourslash/completionListIsGlobalCompletion.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference path='fourslash.ts'/>
22

3+
//@Filename: file.tsx
34
/////// <reference path="/*1*/..\services\services.ts" /> // no globals in reference paths
45
////import { /*2*/ } from "./file.ts"; // no globals in imports
56
////var test = "/*3*/"; // no globals in strings
@@ -20,6 +21,7 @@
2021
//// /*9*/ // insert globals
2122
////}
2223
/////*10*/ // insert globals
24+
////const y = <div /*11*/ />;
2325
goTo.marker("1");
2426
verify.completionListIsGlobal(false);
2527
goTo.marker("2");
@@ -40,3 +42,5 @@ goTo.marker("9");
4042
verify.completionListIsGlobal(true);
4143
goTo.marker("10");
4244
verify.completionListIsGlobal(true);
45+
goTo.marker("11");
46+
verify.completionListIsGlobal(false);

0 commit comments

Comments
 (0)