mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fix indentation
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}`);
|
||||
|
||||
Reference in New Issue
Block a user