diff --git a/src/services/formatting.ts b/src/services/formatting/formatting.ts
similarity index 93%
rename from src/services/formatting.ts
rename to src/services/formatting/formatting.ts
index 48d3c80445c..f0252a254c3 100644
--- a/src/services/formatting.ts
+++ b/src/services/formatting/formatting.ts
@@ -1,7 +1,6 @@
-///
-///
-///
-///
+///
+///
+///
module ts.formatting {
@@ -991,4 +990,56 @@ module ts.formatting {
return SyntaxKind.Unknown;
}
+
+ var internedTabsIndentation: string[];
+ var internedSpacesIndentation: string[];
+
+ export function getIndentationString(indentation: number, options: FormatCodeOptions): string {
+ if (!options.ConvertTabsToSpaces) {
+ var tabs = Math.floor(indentation / options.TabSize);
+ var spaces = indentation - tabs * options.TabSize;
+
+ var tabString: string;
+ if (!internedTabsIndentation) {
+ internedTabsIndentation = [];
+ }
+
+ if (internedTabsIndentation[tabs] === undefined) {
+ internedTabsIndentation[tabs] = tabString = repeat('\t', tabs);
+ }
+ else {
+ tabString = internedTabsIndentation[tabs];
+ }
+
+ return spaces ? tabString + repeat(" ", spaces) : tabString;
+ }
+ else {
+ var spacesString: string;
+ var quotient = Math.floor(indentation / options.IndentSize);
+ var remainder = indentation % options.IndentSize;
+ if (!internedSpacesIndentation) {
+ internedSpacesIndentation = [];
+ }
+
+ if (internedSpacesIndentation[quotient] === undefined) {
+ spacesString = repeat(" ", options.IndentSize * quotient);
+ internedSpacesIndentation[quotient] = spacesString;
+ }
+ else {
+ spacesString = internedSpacesIndentation[quotient];
+ }
+
+
+ return remainder ? spacesString + repeat(" ", remainder) : spacesString;
+ }
+
+ function repeat(value: string, count: number): string {
+ var s = "";
+ for (var i = 0; i < count; ++i) {
+ s += value;
+ }
+
+ return s;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts
index 710881bf80b..7ddfecc17f2 100644
--- a/src/services/formatting/formattingScanner.ts
+++ b/src/services/formatting/formattingScanner.ts
@@ -1,4 +1,4 @@
-///
+///
///
module ts.formatting {
diff --git a/src/services/smartIndenter.ts b/src/services/formatting/smartIndenter.ts
similarity index 97%
rename from src/services/smartIndenter.ts
rename to src/services/formatting/smartIndenter.ts
index 758c06226a4..f6f5031d60e 100644
--- a/src/services/smartIndenter.ts
+++ b/src/services/formatting/smartIndenter.ts
@@ -1,4 +1,4 @@
-///
+///
module ts.formatting {
export module SmartIndenter {
diff --git a/src/services/services.ts b/src/services/services.ts
index 66269f8655a..df8cae5900e 100644
--- a/src/services/services.ts
+++ b/src/services/services.ts
@@ -4,13 +4,13 @@
///
///
+///
///
///
-///
///
///
-///
-///
+///
+///
module ts {