From 153b94aeb4931437802d02e193be88f5240a1978 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 16 Aug 2017 15:28:47 -0700 Subject: [PATCH] `JsxText` has no leading comments --- src/compiler/utilities.ts | 2 +- .../fourslash/isInMultiLineCommentJsxText.ts | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/isInMultiLineCommentJsxText.ts diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 76d242e8b08..8c82b9d26df 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -635,7 +635,7 @@ namespace ts { } export function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile) { - return getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + return node.kind !== SyntaxKind.JsxText ? getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } export function getLeadingCommentRangesOfNodeFromText(node: Node, text: string) { diff --git a/tests/cases/fourslash/isInMultiLineCommentJsxText.ts b/tests/cases/fourslash/isInMultiLineCommentJsxText.ts new file mode 100644 index 00000000000..db88f6b9a55 --- /dev/null +++ b/tests/cases/fourslash/isInMultiLineCommentJsxText.ts @@ -0,0 +1,27 @@ +/// + +// @Filename: file.jsx +////
+//// // /*0*/ +//// /* /*1*/ */ +//// /** +//// * /*2*/ +//// */ +//// foo() /* /*3*/ */ +//// // /*4*/ +//// /* /*5*/ */ +//// /** +//// * /*6*/ +//// */ +////
+////
+//// // /*7*/ +//// /* /*8*/ */ +//// /** +//// * /*9*/ +//// */ + +for (let i = 0; i < 10; ++i) { + goTo.marker(i.toString()); + verify.not.isInCommentAtPosition(/*onlyMultiLine*/ false); +}