Add fourslash tests & address CR comments

This commit is contained in:
Jason Ramsay
2016-06-24 13:16:58 -07:00
parent 369253bbc4
commit 8c503207be
6 changed files with 491 additions and 16 deletions

View File

@@ -396,10 +396,8 @@ namespace ts.formatting {
if (startLine !== parentStartLine || startPos === column) {
// Use the base indent size if it is greater than
// the indentation of the inherited predecessor.
if (options.BaseIndentSize > column) {
return options.BaseIndentSize;
}
return column;
const baseIndentSize = SmartIndenter.getBaseIndentation(options);
return baseIndentSize > column ? baseIndentSize : column;
}
}

View File

@@ -16,7 +16,7 @@ namespace ts.formatting {
// no indentation when the indent style is set to none,
// so we can return fast
if (options.IndentStyle === IndentStyle.None) {
return getBaseIndentation(options);
return 0;
}
const precedingToken = findPrecedingToken(position, sourceFile);
@@ -27,7 +27,7 @@ namespace ts.formatting {
// no indentation in string \regex\template literals
const precedingTokenIsLiteral = isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind);
if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) {
return getBaseIndentation(options);
return 0;
}
const lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
@@ -103,7 +103,7 @@ namespace ts.formatting {
return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options);
}
function getBaseIndentation(options: EditorOptions) {
export function getBaseIndentation(options: EditorOptions) {
return options.BaseIndentSize || 0;
}