fix(43292): forbid highlighting multiline template strings (#46531)

This commit is contained in:
Oleksandr T
2021-11-01 23:21:38 +02:00
committed by GitHub
parent fa2ad1a35a
commit 5142e37f2d
3 changed files with 30 additions and 1 deletions

View File

@@ -2021,7 +2021,8 @@ namespace ts.FindAllReferences {
}
}
else {
return nodeEntry(ref, EntryKind.StringLiteral);
return isNoSubstitutionTemplateLiteral(ref) && !rangeIsOnSingleLine(ref, sourceFile) ? undefined :
nodeEntry(ref, EntryKind.StringLiteral);
}
}
});

View File

@@ -0,0 +1,10 @@
/// <reference path='fourslash.ts'/>
////const foo = `
//// a
//// [|b|]
//// c
////`
const [r] = test.ranges();
verify.noDocumentHighlights(r);

View File

@@ -0,0 +1,18 @@
/// <reference path='fourslash.ts'/>
////type Foo = "[|a|]" | "b";
////
////class C {
//// p: Foo = `[|a|]`;
//// m() {
//// switch (this.p) {
//// case `[|a|]`:
//// return 1;
//// case "b":
//// return 2;
//// }
//// }
////}
const [r0, r1, r2] = test.ranges();
verify.documentHighlightsOf(r2, [r0, r1, r2]);