Skip to content

Commit

Permalink
Output +/- on diff so added/removed empty lines are visible. (palanti…
Browse files Browse the repository at this point in the history
  • Loading branch information
NaridaL authored and suchanlee committed Jun 28, 2018
1 parent 6989dd7 commit 4a11f95
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,17 @@ function displayDiffResults(diffResults: diff.IDiffResult[], extension: string,

for (const diffResult of diffResults) {
let color = chalk.grey;
let prefix = " ";
if (diffResult.added) {
color = chalk.green.underline;
prefix = "+ ";
} else if (diffResult.removed) {
color = chalk.red.underline;
prefix = "- ";
}
logger.log(color(diffResult.value));
logger.log(color(diffResult.value.split(/\r\n|\r|\n/)
// strings end on a newline which we do not want to include the prefix.
// tslint:disable-next-line:prefer-template
.map((line, index, array) => index === array.length - 1 ? line : prefix + line + "\n").join("")));
}
}

0 comments on commit 4a11f95

Please sign in to comment.