remove the new line after targeted line

This commit is contained in:
zhengbli
2017-02-08 19:11:42 -08:00
parent dc78d3314f
commit 80568c5326

View File

@@ -150,7 +150,20 @@ namespace ts.codefix {
}
function createCodeFixToRemoveNode(node: Node) {
return createCodeFix("", node.getStart(), node.getWidth());
let end = node.getEnd();
const endCharCode = sourceFile.text.charCodeAt(end);
const afterEndCharCode = sourceFile.text.charCodeAt(end + 1);
if (isLineBreak(endCharCode)) {
end += 1;
}
// in the case of CR LF, you could have two consecutive new line characters for one new line.
// this needs to be differenciated from two LF LF chars that actually mean two new lines.
if (isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) {
end += 1;
}
const start = node.getStart();
return createCodeFix("", start, end - start);
}
function findFirstNonSpaceCharPosStarting(start: number) {