File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -866,13 +866,23 @@ namespace ts.formatting {
866866 }
867867 else {
868868 let tokenStart = sourceFile . getLineAndCharacterOfPosition ( pos ) ;
869- if ( indentation !== tokenStart . character ) {
870- let startLinePosition = getStartPositionOfLine ( tokenStart . line , sourceFile ) ;
869+ let startLinePosition = getStartPositionOfLine ( tokenStart . line , sourceFile ) ;
870+ if ( indentation !== tokenStart . character || indentationIsDifferent ( indentationString , startLinePosition ) ) {
871871 recordReplace ( startLinePosition , tokenStart . character , indentationString ) ;
872872 }
873873 }
874874 }
875875
876+ function indentationIsDifferent ( indentationString : string , startLinePosition : number ) : boolean {
877+ let size = indentationString . length ;
878+ for ( let i = 0 ; i < size ; i ++ ) {
879+ if ( indentationString . charCodeAt ( i ) !== sourceFile . text . charCodeAt ( startLinePosition + i ) ) {
880+ return true ;
881+ }
882+ }
883+ return false ;
884+ }
885+
876886 function indentMultilineComment ( commentRange : TextRange , indentation : number , firstLineIsIndented : boolean ) {
877887 // split comment in lines
878888 let startLine = sourceFile . getLineAndCharacterOfPosition ( commentRange . pos ) . line ;
@@ -1152,4 +1162,4 @@ namespace ts.formatting {
11521162 return s ;
11531163 }
11541164 }
1155- }
1165+ }
You can’t perform that action at this time.
0 commit comments