mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Make 'getIndentString' just use a loop. (#41221)
* Make 'getIndentString' just use a loop. * Added test. * Accepted baselines.
This commit is contained in:
1 parent
6c298474e4
commit
3517af8f80
5 files changed
+51
-2
No files matched your search
@@ -3849,8 +3849,10 @@ namespace ts {
|
||||
|
||||
const indentStrings: string[] = ["", " "];
|
||||
export function getIndentString(level: number) {
|
||||
if (indentStrings[level] === undefined) {
|
||||
indentStrings[level] = getIndentString(level - 1) + indentStrings[1];
|
||||
// prepopulate cache
|
||||
const singleLevel = indentStrings[1];
|
||||
for (let current = indentStrings.length; current <= level; current++) {
|
||||
indentStrings.push(indentStrings[current - 1] + singleLevel);
|
||||
}
|
||||
return indentStrings[level];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
//// [commentWithUnreasonableIndentationLevel01.ts]
|
||||
// Repro from #41223
|
||||
|
||||
/**
|
||||
Line truncated
|
||||
*/
|
||||
export class SomeAutoGeneratedThing {}
|
||||
|
||||
//// [commentWithUnreasonableIndentationLevel01.js]
|
||||
"use strict";
|
||||
// Repro from #41223
|
||||
exports.__esModule = true;
|
||||
exports.SomeAutoGeneratedThing = void 0;
|
||||
/**
|
||||
Line truncated
|
||||
*/
|
||||
var SomeAutoGeneratedThing = /** @class */ (function () {
|
||||
function SomeAutoGeneratedThing() {
|
||||
}
|
||||
return SomeAutoGeneratedThing;
|
||||
}());
|
||||
exports.SomeAutoGeneratedThing = SomeAutoGeneratedThing;
|
||||
@@ -0,0 +1,9 @@
|
||||
=== tests/cases/compiler/commentWithUnreasonableIndentationLevel01.ts ===
|
||||
// Repro from #41223
|
||||
|
||||
/**
|
||||
Line truncated
|
||||
*/
|
||||
export class SomeAutoGeneratedThing {}
|
||||
>SomeAutoGeneratedThing : Symbol(SomeAutoGeneratedThing, Decl(commentWithUnreasonableIndentationLevel01.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
=== tests/cases/compiler/commentWithUnreasonableIndentationLevel01.ts ===
|
||||
// Repro from #41223
|
||||
|
||||
/**
|
||||
Line truncated
|
||||
*/
|
||||
export class SomeAutoGeneratedThing {}
|
||||
>SomeAutoGeneratedThing : SomeAutoGeneratedThing
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
// Repro from #41223
|
||||
|
||||
/**
|
||||
Line truncated
|
||||
*/
|
||||
export class SomeAutoGeneratedThing {}
|
||||
Reference in new issue
Block a user