Fix the tab and indent calculation when formatting comments in the emitted output

This commit is contained in:
Sheetal Nandi
2014-08-29 20:49:47 -07:00
parent 655039c9c7
commit 816b018ae2
6 changed files with 94 additions and 7 deletions

View File

@@ -296,11 +296,10 @@ module ts {
function calculateIndent(pos: number, end: number) {
var currentLineIndent = 0;
while (pos < end && isWhiteSpace(currentSourceFile.text.charCodeAt(pos))) {
pos++;
for (; pos < end && isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) {
if (currentSourceFile.text.charCodeAt(pos) === CharacterCodes.tab) {
// Tabs = size of the indent
currentLineIndent += getIndentSize();
// Tabs = TabSize = indent size and go to next tabStop
currentLineIndent += (getIndentSize() - currentLineIndent % getIndentSize());
}
else {
// Single space