File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1008,10 +1008,20 @@ module ts.formatting {
10081008 return SyntaxKind . Unknown ;
10091009 }
10101010
1011- let internedTabsIndentation : string [ ] ;
1012- let internedSpacesIndentation : string [ ] ;
1011+ var internedSizes : { tabSize : number ; indentSize : number } ;
1012+ var internedTabsIndentation : string [ ] ;
1013+ var internedSpacesIndentation : string [ ] ;
10131014
10141015 export function getIndentationString ( indentation : number , options : FormatCodeOptions ) : string {
1016+ // reset interned strings if FormatCodeOptions were changed
1017+ let resetInternedStrings =
1018+ ! internedSizes || ( internedSizes . tabSize !== options . TabSize || internedSizes . indentSize !== options . IndentSize ) ;
1019+
1020+ if ( resetInternedStrings ) {
1021+ internedSizes = { tabSize : options . TabSize , indentSize : options . IndentSize } ;
1022+ internedTabsIndentation = internedSpacesIndentation = undefined ;
1023+ }
1024+
10151025 if ( ! options . ConvertTabsToSpaces ) {
10161026 let tabs = Math . floor ( indentation / options . TabSize ) ;
10171027 let spaces = indentation - tabs * options . TabSize ;
Load diff This file was deleted.
Original file line number Diff line number Diff line change 1+ /// <reference path='fourslash.ts'/>
2+
3+ ////module M {
4+ /////*1*/var x=1;
5+ //// }
6+
7+ var originalOptions = format . copyFormatOptions ( ) ;
8+
9+ format . document ( ) ;
10+
11+ goTo . marker ( "1" ) ;
12+ verify . currentLineContentIs ( " var x = 1;" ) ;
13+
14+ var copy = format . copyFormatOptions ( ) ;
15+ copy . TabSize = 2 ;
16+ copy . IndentSize = 2 ;
17+
18+ format . setFormatOptions ( copy ) ;
19+ format . document ( ) ;
20+
21+ goTo . marker ( "1" ) ;
22+ verify . currentLineContentIs ( " var x = 1;" ) ;
23+
24+ format . setFormatOptions ( originalOptions ) ;
You can’t perform that action at this time.
0 commit comments