Fixes space-tab indentation issues

This commit is contained in:
František Žiačik 2016-05-05 23:23:25 +02:00
parent ba2a33049c
commit 06d05b079e

View file

@ -866,13 +866,23 @@ namespace ts.formatting {
}
else {
let tokenStart = sourceFile.getLineAndCharacterOfPosition(pos);
if (indentation !== tokenStart.character) {
let startLinePosition = getStartPositionOfLine(tokenStart.line, sourceFile);
let startLinePosition = getStartPositionOfLine(tokenStart.line, sourceFile);
if (indentation !== tokenStart.character || indentationIsDifferent(indentationString, startLinePosition)) {
recordReplace(startLinePosition, tokenStart.character, indentationString);
}
}
}
function indentationIsDifferent(indentationString: string, startLinePosition: number): boolean {
let size = indentationString.length;
for (let i = 0; i < size; i++) {
if (indentationString.charCodeAt(i) !== sourceFile.text.charCodeAt(startLinePosition + i)) {
return true;
}
}
return false;
}
function indentMultilineComment(commentRange: TextRange, indentation: number, firstLineIsIndented: boolean) {
// split comment in lines
let startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line;
@ -1152,4 +1162,4 @@ namespace ts.formatting {
return s;
}
}
}
}