diff --git a/lib/widget.js b/lib/widget.js index f85905b..4df7bd7 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -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;