fix cut-off tags when wrapping is disabled. fixes #50.

This commit is contained in:
Christopher Jeffrey 2014-04-26 05:06:19 -05:00
parent 6694b35ee4
commit c0f85b2567

View File

@ -2163,7 +2163,8 @@ Element.prototype._wrapContent = function(content, width) {
, i
, part
, j
, lines;
, lines
, rest;
lines = content.split('\n');
@ -2202,12 +2203,6 @@ main:
}
}
// If we're not wrapping, just chop
// the string off at the width.
if (!wrap && line.length > width) {
line = line.slice(0, width);
}
// If the string is apparently too long, wrap it.
while (line.length > width) {
// Measure the real width of the string.
@ -2217,6 +2212,16 @@ main:
}
if (!line[i]) break;
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.
if (!wrap) {
rest = line.substring(i).match(/\x1b\[[^m]*m/g);
rest = rest ? rest.join('') : '';
out.push(this._align(line.substring(0, i) + rest, width, align));
ftor[no].push(out.length - 1);
rtof.push(no);
continue main;
}
// Try to find a space to break on.
if (line[i] !== ' ') {
j = i;