Fixes last character cropping bug

This commit is contained in:
Dan Kaplun 2014-04-26 08:05:49 -05:00
parent 47ead5ea93
commit 832f47d2c5

View File

@ -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;
}