Fix indentation

This commit is contained in:
Andrew Branch
2019-09-11 14:58:48 -07:00
parent ae9a234de0
commit 0ac2807216
5 changed files with 26 additions and 17 deletions
+1 -1
View File
@@ -1191,7 +1191,7 @@ namespace ts.formatting {
break;
case RuleAction.DeleteToken:
recordDelete(previousRange.pos, previousRange.end - previousRange.pos);
return onLaterLine ? LineAction.LineRemoved : LineAction.None;
break;
case RuleAction.NewLine:
// exit early if we on different lines and rule cannot change number of newlines
// if line1 and line2 are on subsequent lines then no edits are required - ok to exit
+8 -5
View File
@@ -778,15 +778,18 @@ namespace ts.formatting {
}
function isSemicolonDeletionContext(context: FormattingContext): boolean {
if (context.TokensAreOnSameLine()) {
return context.nextTokenSpan.kind === SyntaxKind.CloseBraceToken
|| context.nextTokenSpan.kind === SyntaxKind.EndOfFileToken;
}
const nextToken = isTrivia(context.nextTokenSpan.kind)
? context.nextTokenParent.getChildAt(0)
: context.nextTokenSpan;
const startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line;
const endLine = context.sourceFile.getLineAndCharacterOfPosition(nextToken.pos).line;
if (startLine === endLine) {
return nextToken.kind === SyntaxKind.CloseBraceToken
|| nextToken.kind === SyntaxKind.EndOfFileToken;
}
if (nextToken.kind === SyntaxKind.SemicolonClassElement ||
nextToken.kind === SyntaxKind.SemicolonToken
) {
+1 -1
View File
@@ -758,7 +758,7 @@ namespace ts {
insertSpaceBeforeFunctionParenthesis: false,
placeOpenBraceOnNewLineForFunctions: false,
placeOpenBraceOnNewLineForControlBlocks: false,
// insertTrailingSemicolon: false,
insertTrailingSemicolon: false,
};
}
@@ -43,9 +43,9 @@ verify.currentFileContentIs(`; (function f() { })()
const a = 3;
+ 4
const b = 3
+ 4
+ 4
const c = 3 +
4
4
class C {
prop
["p"]
@@ -1,15 +1,21 @@
/// <reference path="fourslash.ts" />
////interface I {
//// a: string;
//// /** @internal */
//// b: string;
////namespace ts {
//// let x = 0;
//// interface I {
//// a: string;
//// /** @internal */
//// b: string;
//// }
////}
format.setFormatOptions({ ...format.copyFormatOptions(), insertTrailingSemicolon: false });
format.document();
verify.currentFileContentIs(`interface I {
a: string
/** @internal */
b: string
verify.currentFileContentIs(`namespace ts {
let x = 0
interface I {
a: string
/** @internal */
b: string
}
}`);