Skip to content

Commit 5142e37

Browse files
authored
fix(43292): forbid highlighting multiline template strings (#46531)
1 parent fa2ad1a commit 5142e37

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/services/findAllReferences.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2021,7 +2021,8 @@ namespace ts.FindAllReferences {
20212021
}
20222022
}
20232023
else {
2024-
return nodeEntry(ref, EntryKind.StringLiteral);
2024+
return isNoSubstitutionTemplateLiteral(ref) && !rangeIsOnSingleLine(ref, sourceFile) ? undefined :
2025+
nodeEntry(ref, EntryKind.StringLiteral);
20252026
}
20262027
}
20272028
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////const foo = `
4+
//// a
5+
//// [|b|]
6+
//// c
7+
////`
8+
9+
const [r] = test.ranges();
10+
verify.noDocumentHighlights(r);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////type Foo = "[|a|]" | "b";
4+
////
5+
////class C {
6+
//// p: Foo = `[|a|]`;
7+
//// m() {
8+
//// switch (this.p) {
9+
//// case `[|a|]`:
10+
//// return 1;
11+
//// case "b":
12+
//// return 2;
13+
//// }
14+
//// }
15+
////}
16+
17+
const [r0, r1, r2] = test.ranges();
18+
verify.documentHighlightsOf(r2, [r0, r1, r2]);

0 commit comments

Comments
 (0)