diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index fc3f845dc4..c00db972de 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -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 diff --git a/tests/baselines/reference/commentsFormatting.js b/tests/baselines/reference/commentsFormatting.js index 4ad0d8d6f2..6dc68b06b9 100644 --- a/tests/baselines/reference/commentsFormatting.js +++ b/tests/baselines/reference/commentsFormatting.js @@ -67,6 +67,23 @@ this is 4 spaces left aligned but above line is empty above 3 lines are empty*/ export class c3 { } + + /** this is first line - aligned to class declaration + * this is 0 space + tab + * this is 1 space + tab + * this is 2 spaces + tab + * this is 3 spaces + tab + * this is 4 spaces + tab + * this is 5 spaces + tab + * this is 6 spaces + tab + * this is 7 spaces + tab + * this is 8 spaces + tab + * this is 9 spaces + tab + * this is 10 spaces + tab + * this is 11 spaces + tab + * this is 12 spaces + tab */ + export class c4 { + } } //// [commentsFormatting.js] @@ -148,6 +165,26 @@ this is 4 spaces left aligned but above line is empty return c3; })(); m.c3 = c3; + /** this is first line - aligned to class declaration + * this is 0 space + tab + * this is 1 space + tab + * this is 2 spaces + tab + * this is 3 spaces + tab + * this is 4 spaces + tab + * this is 5 spaces + tab + * this is 6 spaces + tab + * this is 7 spaces + tab + * this is 8 spaces + tab + * this is 9 spaces + tab + * this is 10 spaces + tab + * this is 11 spaces + tab + * this is 12 spaces + tab */ + var c4 = (function () { + function c4() { + } + return c4; + })(); + m.c4 = c4; })(m || (m = {})); @@ -217,4 +254,20 @@ this is 4 spaces left aligned but above line is empty above 3 lines are empty*/ class c3 { } + /** this is first line - aligned to class declaration + * this is 0 space + tab + * this is 1 space + tab + * this is 2 spaces + tab + * this is 3 spaces + tab + * this is 4 spaces + tab + * this is 5 spaces + tab + * this is 6 spaces + tab + * this is 7 spaces + tab + * this is 8 spaces + tab + * this is 9 spaces + tab + * this is 10 spaces + tab + * this is 11 spaces + tab + * this is 12 spaces + tab */ + class c4 { + } } diff --git a/tests/baselines/reference/commentsFormatting.types b/tests/baselines/reference/commentsFormatting.types index 62e8941b18..2de53654f9 100644 --- a/tests/baselines/reference/commentsFormatting.types +++ b/tests/baselines/reference/commentsFormatting.types @@ -72,4 +72,22 @@ this is 4 spaces left aligned but above line is empty export class c3 { >c3 : c3 } + + /** this is first line - aligned to class declaration + * this is 0 space + tab + * this is 1 space + tab + * this is 2 spaces + tab + * this is 3 spaces + tab + * this is 4 spaces + tab + * this is 5 spaces + tab + * this is 6 spaces + tab + * this is 7 spaces + tab + * this is 8 spaces + tab + * this is 9 spaces + tab + * this is 10 spaces + tab + * this is 11 spaces + tab + * this is 12 spaces + tab */ + export class c4 { +>c4 : c4 + } } diff --git a/tests/baselines/reference/enumBasics1.js b/tests/baselines/reference/enumBasics1.js index b6c8c75f33..13b6da353b 100644 --- a/tests/baselines/reference/enumBasics1.js +++ b/tests/baselines/reference/enumBasics1.js @@ -55,9 +55,9 @@ foo(a); // shouldn't error class C { - public e: E; + public e: E; - public m(): E { return this.e; } // shouldn't error + public m(): E { return this.e; } // shouldn't error } diff --git a/tests/baselines/reference/genericArray1.js b/tests/baselines/reference/genericArray1.js index 74b66515dc..b0bfcd2201 100644 --- a/tests/baselines/reference/genericArray1.js +++ b/tests/baselines/reference/genericArray1.js @@ -23,7 +23,7 @@ map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U } interface String{ - length: number; + length: number; } */ var lengths = ["a", "b", "c"].map(function (x) { return x.length; }); diff --git a/tests/cases/compiler/commentsFormatting.ts b/tests/cases/compiler/commentsFormatting.ts index d7e388a934..b413f0f92e 100644 --- a/tests/cases/compiler/commentsFormatting.ts +++ b/tests/cases/compiler/commentsFormatting.ts @@ -69,4 +69,21 @@ this is 4 spaces left aligned but above line is empty above 3 lines are empty*/ export class c3 { } + + /** this is first line - aligned to class declaration + * this is 0 space + tab + * this is 1 space + tab + * this is 2 spaces + tab + * this is 3 spaces + tab + * this is 4 spaces + tab + * this is 5 spaces + tab + * this is 6 spaces + tab + * this is 7 spaces + tab + * this is 8 spaces + tab + * this is 9 spaces + tab + * this is 10 spaces + tab + * this is 11 spaces + tab + * this is 12 spaces + tab */ + export class c4 { + } } \ No newline at end of file