mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 01:49:57 -05:00
fix formatting for chained callbacks
This commit is contained in:
@@ -323,6 +323,9 @@ module ts.formatting {
|
||||
let previousParent: Node;
|
||||
let previousRangeStartLine: number;
|
||||
|
||||
let lastIndentedLine: number;
|
||||
let indentationOnLastIndentedLine: number;
|
||||
|
||||
let edits: TextChange[] = [];
|
||||
|
||||
formattingScanner.advance();
|
||||
@@ -416,7 +419,7 @@ module ts.formatting {
|
||||
// if node is located on the same line with the parent
|
||||
// - inherit indentation from the parent
|
||||
// - push children if either parent of node itself has non-zero delta
|
||||
indentation = parentDynamicIndentation.getIndentation();
|
||||
indentation = startLine === lastIndentedLine ? indentationOnLastIndentedLine : parentDynamicIndentation.getIndentation();
|
||||
delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta);
|
||||
}
|
||||
return {
|
||||
@@ -716,7 +719,6 @@ module ts.formatting {
|
||||
continue;
|
||||
}
|
||||
|
||||
let triviaStartLine = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos).line;
|
||||
switch (triviaItem.kind) {
|
||||
case SyntaxKind.MultiLineCommentTrivia:
|
||||
let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
|
||||
@@ -741,6 +743,9 @@ module ts.formatting {
|
||||
if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) {
|
||||
let tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind);
|
||||
insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded);
|
||||
|
||||
lastIndentedLine = tokenStart.line;
|
||||
indentationOnLastIndentedLine = tokenIndentation;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//// .resolve()
|
||||
//// .then(() => {/*1*/""/*2*/
|
||||
////}).then(() => {/*3*//*4*/
|
||||
////})/*semi1*/ /*semi2*/
|
||||
////})/*semi1*//*semi2*/
|
||||
|
||||
////function foo() {
|
||||
//// return Promise.resolve()
|
||||
@@ -16,8 +16,7 @@
|
||||
goTo.marker('1');
|
||||
edit.insertLine('');
|
||||
goTo.marker('2');
|
||||
// Expected, with bug 1888: verify.currentLineContentIs(' ""');
|
||||
verify.currentLineContentIs(' ""');
|
||||
verify.currentLineContentIs(' ""');
|
||||
goTo.marker('4');
|
||||
edit.insertLine('');
|
||||
goTo.marker('3');
|
||||
@@ -25,8 +24,7 @@ verify.currentLineContentIs(' }).then(() => {');
|
||||
|
||||
goTo.marker("semi1");
|
||||
edit.insert(';');
|
||||
// Expected, with bug 1888: verify.currentLineContentIs(' });');
|
||||
verify.currentLineContentIs('}); ');
|
||||
verify.currentLineContentIs(' });');
|
||||
goTo.marker("semi2");
|
||||
edit.insert(';');
|
||||
verify.currentLineContentIs(' });;');
|
||||
@@ -36,5 +34,4 @@ edit.insert(';');
|
||||
verify.currentLineContentIs(' "";');
|
||||
goTo.marker('b');
|
||||
edit.insert(';');
|
||||
// Expected, with bug 1888: verify.currentLineContentIs(' });');
|
||||
verify.currentLineContentIs(' });');
|
||||
verify.currentLineContentIs(' });');
|
||||
Reference in New Issue
Block a user