diff --git a/src/compiler/program.ts b/src/compiler/program.ts index d6ed0b10648..e6a53885000 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -407,7 +407,7 @@ namespace ts { const lineEnd = i < lastLineInFile ? getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; let lineContent = file.text.slice(lineStart, lineEnd); lineContent = lineContent.replace(/\s+$/g, ""); // trim from end - lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces + lineContent = lineContent.replace(/\t/g, " "); // convert tabs to single spaces // Output the gutter and the actual contents of the line. context += indent + formatColorAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; diff --git a/tests/baselines/reference/prettyFileWithErrorsAndTabs.errors.txt b/tests/baselines/reference/prettyFileWithErrorsAndTabs.errors.txt new file mode 100644 index 00000000000..e0727c9429b --- /dev/null +++ b/tests/baselines/reference/prettyFileWithErrorsAndTabs.errors.txt @@ -0,0 +1,30 @@ +tests/cases/compiler/prettyFileWithErrorsAndTabs.ts:3:9 - error TS2322: Type 'number' is not assignable to type 'string'. + +3 const x: string = 12; +   ~ +tests/cases/compiler/prettyFileWithErrorsAndTabs.ts:4:9 - error TS2322: Type 'number' is not assignable to type 'string'. + +4 const y: string = 12; +   ~ +tests/cases/compiler/prettyFileWithErrorsAndTabs.ts:5:9 - error TS2322: Type 'number' is not assignable to type 'string'. + +5 const z: string = 12; +   ~ + + +==== tests/cases/compiler/prettyFileWithErrorsAndTabs.ts (3 errors) ==== + function f() { + { + const x: string = 12; + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + const y: string = 12; + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + const z: string = 12; + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + } + } +Found 3 errors. + diff --git a/tests/baselines/reference/prettyFileWithErrorsAndTabs.js b/tests/baselines/reference/prettyFileWithErrorsAndTabs.js new file mode 100644 index 00000000000..ca6d2424f56 --- /dev/null +++ b/tests/baselines/reference/prettyFileWithErrorsAndTabs.js @@ -0,0 +1,17 @@ +//// [prettyFileWithErrorsAndTabs.ts] +function f() { + { + const x: string = 12; + const y: string = 12; + const z: string = 12; + } +} + +//// [prettyFileWithErrorsAndTabs.js] +function f() { + { + var x = 12; + var y = 12; + var z = 12; + } +} diff --git a/tests/baselines/reference/prettyFileWithErrorsAndTabs.symbols b/tests/baselines/reference/prettyFileWithErrorsAndTabs.symbols new file mode 100644 index 00000000000..a009e897037 --- /dev/null +++ b/tests/baselines/reference/prettyFileWithErrorsAndTabs.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/prettyFileWithErrorsAndTabs.ts === +function f() { +>f : Symbol(f, Decl(prettyFileWithErrorsAndTabs.ts, 0, 0)) + { + const x: string = 12; +>x : Symbol(x, Decl(prettyFileWithErrorsAndTabs.ts, 2, 7)) + + const y: string = 12; +>y : Symbol(y, Decl(prettyFileWithErrorsAndTabs.ts, 3, 7)) + + const z: string = 12; +>z : Symbol(z, Decl(prettyFileWithErrorsAndTabs.ts, 4, 7)) + } +} diff --git a/tests/baselines/reference/prettyFileWithErrorsAndTabs.types b/tests/baselines/reference/prettyFileWithErrorsAndTabs.types new file mode 100644 index 00000000000..660ce754170 --- /dev/null +++ b/tests/baselines/reference/prettyFileWithErrorsAndTabs.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/prettyFileWithErrorsAndTabs.ts === +function f() { +>f : () => void + { + const x: string = 12; +>x : string +>12 : 12 + + const y: string = 12; +>y : string +>12 : 12 + + const z: string = 12; +>z : string +>12 : 12 + } +} diff --git a/tests/cases/compiler/prettyFileWithErrorsAndTabs.ts b/tests/cases/compiler/prettyFileWithErrorsAndTabs.ts new file mode 100644 index 00000000000..e2aacbf0af6 --- /dev/null +++ b/tests/cases/compiler/prettyFileWithErrorsAndTabs.ts @@ -0,0 +1,8 @@ +// @pretty: true +function f() { + { + const x: string = 12; + const y: string = 12; + const z: string = 12; + } +} \ No newline at end of file