Skip to content

Commit

Permalink
[Bugfix] dumpInlineDiffToConsole should always use a fixed column wid…
Browse files Browse the repository at this point in the history
…th for the image

There were issues with iTerm rendering with the previous width settings. This ensures the width of the image is 40 characters wide.
  • Loading branch information
LukeChannings authored Dec 11, 2020
1 parent 70a3817 commit 56534d5
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ function checkResult({
];

if (dumpInlineDiffToConsole && (supportedInlineTerms.includes(process.env.TERM_PROGRAM) || 'ENABLE_INLINE_DIFF' in process.env)) {
const { receivedHeight, receivedWidth } = result.imageDimensions;
const height = 20;
const width = Math.round(((receivedHeight) / (receivedWidth * 3)) * height);
failure += `\n\n\t\x1b]1337;File=name=${Buffer.from(result.diffOutputPath).toString('base64')};inline=1;height=${height};width=${width}:${result.imgSrcString.replace('data:image/png;base64,', '')}\x07\x1b\n\n`;
failure += `\n\n\t\x1b]1337;File=name=${Buffer.from(result.diffOutputPath).toString('base64')};inline=1;width=40:${result.imgSrcString.replace('data:image/png;base64,', '')}\x07\x1b\n\n`;
} else if (dumpDiffToConsole || dumpInlineDiffToConsole) {
failure += `\n${chalk.bold.red('Or paste below image diff string to your browser`s URL bar.')}\n ${result.imgSrcString}`;
}
Expand Down

0 comments on commit 56534d5

Please sign in to comment.