From 832f47d2c5ad7e217354da227d15497a60bb7553 Mon Sep 17 00:00:00 2001 From: Dan Kaplun Date: Sat, 26 Apr 2014 08:05:49 -0500 Subject: [PATCH] Fixes last character cropping bug --- lib/widget.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/widget.js b/lib/widget.js index ae8386c..cfc22b1 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -2229,6 +2229,7 @@ main: if (++total === width) { // If we're not wrapping the text, we have to finish up the rest of // the control sequences before cutting off the line. + i++; if (!wrap) { rest = line.substring(i).match(/\x1b\[[^m]*m/g); rest = rest ? rest.join('') : ''; @@ -2238,12 +2239,10 @@ main: continue main; } // Try to find a space to break on. - if (line[i] !== ' ') { + if (i !== line.length) { j = i; - while (j > i - 10 && j > 0 && line[j] !== ' ') j--; + while (j > i - 10 && j > 0 && line[--j] !== ' '); if (line[j] === ' ') i = j + 1; - } else { - i++; } break; }