Just squiggle the entire line for middle lines (sans trailing space).

This commit is contained in:
Daniel Rosenwasser
2015-07-01 03:49:58 -04:00
parent f660bd3652
commit 17f443ac3b

View File

@@ -116,23 +116,21 @@ namespace ts {
output += lineContent + sys.newLine;
output += redColorControlChar;
if (i === 0) {
let lastCharForLine = i === indexOfLastLine ? lastLineChar : undefined;
output += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
output += redColorControlChar;
output += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~");
output += resetColorControlChar;
}
else if (i === indexOfLastLine) {
output += redColorControlChar;
output += lineContent.slice(0, lastLineChar).replace(/./g, "~");
output += resetColorControlChar;
// Don't bother "filling" at the end.
}
else {
output += lineContent.replace(/^(\s*)(.*)$/, replaceLineWithRedSquiggles);
output += lineContent.replace(/./g, "~");
}
output += resetColorControlChar;
output += sys.newLine;
}
@@ -147,10 +145,6 @@ namespace ts {
sys.write(output);
}
function replaceLineWithRedSquiggles(orig: string, leadingWhitespace: string, content: string): string {
return leadingWhitespace + redColorControlChar + content.replace(/./g, "~") + resetColorControlChar;
}
/** Splits the given string on \r\n, or on only \n if that fails, or on only \r if *that* fails. */
function splitContentByNewlines(content: string) {
// Split up the input file by line