From b0c68aad724a2605547900e3b337a1500ba46676 Mon Sep 17 00:00:00 2001 From: Arman Yeghiazaryan Date: Sun, 13 Dec 2020 07:13:56 +0400 Subject: [PATCH] fix available space count on multiline format mode --- .gitignore | 1 + lib/node-progress.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6ff2f90..d905c43 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules *.sock npm-debug.log yarn.lock +.idea \ No newline at end of file diff --git a/lib/node-progress.js b/lib/node-progress.js index 8eb0740..9751f18 100644 --- a/lib/node-progress.js +++ b/lib/node-progress.js @@ -148,7 +148,7 @@ ProgressBar.prototype.render = function (tokens, force) { .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); + var availableSpace = Math.max(0, ...str.replace(':bar', '').split('\n').map(line => this.stream.columns - line.length)); if(availableSpace && process.platform === 'win32'){ availableSpace = availableSpace - 1; }