Skip to content

Commit 16762a4

Browse files
author
zhengbli
committed
Update tests
1 parent fbb73b7 commit 16762a4

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

src/services/formatting/smartIndenter.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@ namespace ts.formatting {
1919
}
2020

2121
// no indentation in string \regex\template literals
22-
let precedingTokenIsLiteral =
23-
precedingToken.kind === SyntaxKind.StringLiteral ||
24-
precedingToken.kind === SyntaxKind.RegularExpressionLiteral ||
25-
precedingToken.kind === SyntaxKind.NoSubstitutionTemplateLiteral ||
26-
precedingToken.kind === SyntaxKind.TemplateHead ||
27-
precedingToken.kind === SyntaxKind.TemplateMiddle ||
28-
precedingToken.kind === SyntaxKind.TemplateTail;
22+
let precedingTokenIsLiteral = isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind);
2923
if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) {
3024
return 0;
3125
}
Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
/// <reference path="fourslash.ts" />
22

3-
////if (true) {
4-
//// let foo = `
5-
/////*
6-
////`/*1*/}
3+
////let noSubTemplate = `/* /*1*/`;
4+
////let templateHead = `/* /*2*/${1 + 2}`;
5+
////let templateMiddle = `/* ${1 + 2 /*3*/}`;
6+
////let templateTail = `/* ${1 + 2} /*4*/`;
77

88
goTo.marker('1');
9-
edit.insert(";");
9+
edit.insert("\n");
1010

11-
verify.currentFileContentIs("if (true) {\n let foo = `\n/* \n`;}");
11+
goTo.marker('2');
12+
edit.insert("\n");
13+
14+
goTo.marker('3');
15+
edit.insert("\n");
16+
17+
goTo.marker('4');
18+
edit.insert("\n");
19+
20+
21+
verify.currentFileContentIs("let noSubTemplate = `/* \n`;\nlet templateHead = `/* \n${1 + 2}`;\nlet templateMiddle = `/* ${1 + 2\n }`;\nlet templateTail = `/* ${1 + 2} \n`;");

0 commit comments

Comments
 (0)