Merge pull request #5353 from Microsoft/tokenFollowingMultilineComment

do not indent token if its start line matches end line of previous to…
This commit is contained in:
Vladimir Matveev
2015-10-21 13:35:55 -07:00
2 changed files with 12 additions and 3 deletions

View File

@@ -695,8 +695,8 @@ namespace ts.formatting {
let tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos);
if (isTokenInRange) {
let rangeHasError = rangeContainsError(currentTokenInfo.token);
// save prevStartLine since processRange will overwrite this value with current ones
let prevStartLine = previousRangeStartLine;
// save previousRange since processRange will overwrite this value with current one
let savePreviousRange = previousRange;
lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation);
if (rangeHasError) {
// do not indent comments\token if token range overlaps with some error
@@ -707,7 +707,9 @@ namespace ts.formatting {
indentToken = lineAdded;
}
else {
indentToken = lastTriviaWasNewLine && tokenStart.line !== prevStartLine;
// indent token only if end line of previous range does not match start line of the token
const prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line;
indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine;
}
}
}

View File

@@ -0,0 +1,7 @@
/// <reference path="fourslash.ts"/>
/////*foo
////*/"123123";
format.document();
verify.currentFileContentIs(`/*foo
*/"123123";`)