Also skip TemplateHeads
This commit is contained in:
parent
fd88e52252
commit
039487c84e
2 changed files with 14 additions and 3 deletions
|
@ -2136,7 +2136,7 @@ namespace ts.server {
|
|||
// TemplateSpans, along with the SyntaxLists containing them,
|
||||
// are a somewhat unintuitive grouping of things that should be
|
||||
// considered independently. Dive in without pushing a selection range.
|
||||
if (isBlock(node) || isTemplateSpan(node) || prevNode && isTemplateHead(prevNode)) {
|
||||
if (isBlock(node) || isTemplateSpan(node) || isTemplateHead(node) || prevNode && isTemplateHead(prevNode)) {
|
||||
parentNode = node;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -273,7 +273,10 @@ type X = {
|
|||
it("works for string literals and template strings", () => {
|
||||
// tslint:disable-next-line:no-invalid-template-strings
|
||||
const getSelectionRange = setup("/file.ts", "`a b ${\n 'c'\n} d`");
|
||||
const locations = getSelectionRange([{ line: 2, offset: 4 }]);
|
||||
const locations = getSelectionRange([
|
||||
{ line: 2, offset: 4 },
|
||||
{ line: 1, offset: 4 },
|
||||
]);
|
||||
assert.deepEqual(locations, [
|
||||
{
|
||||
textSpan: { // c
|
||||
|
@ -298,7 +301,15 @@ type X = {
|
|||
parent: {
|
||||
textSpan: { // whole template string
|
||||
start: { line: 1, offset: 1 },
|
||||
end: { line: 3, offset: 5 } } } } } } }
|
||||
end: { line: 3, offset: 5 } } } } } } },
|
||||
{
|
||||
textSpan: { // whole template string without backticks
|
||||
start: { line: 1, offset: 2 },
|
||||
end: { line: 3, offset: 4 } },
|
||||
parent: {
|
||||
textSpan: { // whole template string
|
||||
start: { line: 1, offset: 1 },
|
||||
end: { line: 3, offset: 5 } } } },
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue