From f8379241011faf2da69aca3453655de3d8b8086e Mon Sep 17 00:00:00 2001 From: FredGan Date: Sat, 7 Nov 2020 15:18:46 +0800 Subject: [PATCH] Fix #187: the last char missed when width exceeds terminal with --- lib/node-progress.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node-progress.js b/lib/node-progress.js index 8eb0740..be19c98 100644 --- a/lib/node-progress.js +++ b/lib/node-progress.js @@ -147,8 +147,8 @@ ProgressBar.prototype.render = function (tokens, force) { .replace(':percent', percent.toFixed(0) + '%') .replace(':rate', Math.round(rate)); - /* compute the available space (non-zero) for the bar */ - var availableSpace = Math.max(0, this.stream.columns - str.replace(':bar', '').length); + /* compute the available space (non-zero) for the bar. We should substract 1 because of the end line feed character*/ + var availableSpace = Math.max(0, this.stream.columns - str.replace(':bar', '').length - 1); if(availableSpace && process.platform === 'win32'){ availableSpace = availableSpace - 1; }