Skip to content

Commit 3429fab

Browse files
Fixed issue with the kinds we check.
1 parent ea30c68 commit 3429fab

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

src/services/services.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,8 +1143,8 @@ module ts {
11431143
InMultiLineCommentTrivia,
11441144
InSingleQuoteStringLiteral,
11451145
InDoubleQuoteStringLiteral,
1146-
InTemplateHeadLiteral, // this could also be a NoSubstitutionTemplateLiteral
1147-
InTemplateMiddleLiteral, //this could also be a TemplateTail
1146+
InTemplateHeadOrNoSubstitutionTemplate,
1147+
InTemplateMiddleOrTail,
11481148
InTemplateSubstitutionPosition,
11491149
}
11501150

@@ -5678,20 +5678,22 @@ module ts {
56785678
text = "/*\n" + text;
56795679
offset = 3;
56805680
break;
5681-
case EndOfLineState.InTemplateHeadLiteral:
5681+
case EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate:
56825682
if (syntacticClassifierAbsent) {
56835683
text = "`\n" + text;
56845684
offset = 2;
56855685
}
56865686
break;
5687-
case EndOfLineState.InTemplateMiddleLiteral:
5687+
case EndOfLineState.InTemplateMiddleOrTail:
56885688
if (syntacticClassifierAbsent) {
5689-
text = "${\n" + text;
5690-
offset = 3;
5689+
text = "}\n" + text;
5690+
offset = 2;
56915691
}
56925692
// fallthrough
56935693
case EndOfLineState.InTemplateSubstitutionPosition:
5694-
templateStack = [SyntaxKind.TemplateHead];
5694+
if (syntacticClassifierAbsent) {
5695+
templateStack = [SyntaxKind.TemplateHead];
5696+
}
56955697
break;
56965698
}
56975699

@@ -5847,11 +5849,14 @@ module ts {
58475849
}
58485850
else if (isTemplateLiteralKind(token) && syntacticClassifierAbsent) {
58495851
if (scanner.isUnterminated()) {
5850-
if (token === SyntaxKind.TemplateMiddle) {
5851-
result.finalLexState = EndOfLineState.InTemplateMiddleLiteral;
5852+
if (token === SyntaxKind.TemplateTail) {
5853+
result.finalLexState = EndOfLineState.InTemplateMiddleOrTail;
5854+
}
5855+
else if (token === SyntaxKind.NoSubstitutionTemplateLiteral) {
5856+
result.finalLexState = EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate;
58525857
}
58535858
else {
5854-
result.finalLexState = EndOfLineState.InTemplateHeadLiteral;
5859+
Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token);
58555860
}
58565861
}
58575862
}

0 commit comments

Comments
 (0)