mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-01-10 19:16:20 +00:00
fix empty lines in wrapContent.
This commit is contained in:
parent
a82ad19110
commit
88da43bfaf
@ -2014,6 +2014,7 @@ Element.prototype._wrapContent = function(content, width) {
|
||||
if (this.type === 'textarea') margin++;
|
||||
if (width > margin) width -= margin;
|
||||
|
||||
main:
|
||||
for (; no < lines.length; no++) {
|
||||
line = lines[no];
|
||||
align = state;
|
||||
@ -2062,6 +2063,7 @@ Element.prototype._wrapContent = function(content, width) {
|
||||
while (line[i] && line[i++] !== 'm');
|
||||
}
|
||||
if (!line[i]) break;
|
||||
//if (!line[i]) { i--; break; }
|
||||
if (++total === width) {
|
||||
// Try to find a space to break on:
|
||||
if (line[i] !== ' ') {
|
||||
@ -2076,34 +2078,32 @@ Element.prototype._wrapContent = function(content, width) {
|
||||
}
|
||||
}
|
||||
|
||||
// XXX This shouldn't be required, but is.
|
||||
i++;
|
||||
//if (line[i]) i++;
|
||||
|
||||
part = line.substring(0, i - 1);
|
||||
esc = /\x1b[\[\d;]*$/.exec(part);
|
||||
|
||||
esc = /\x1b[\[\d;]*$/.exec(part);
|
||||
if (esc) {
|
||||
part = part.slice(0, -esc[0].length);
|
||||
line = line.substring(i - 1 - esc[0].length);
|
||||
out.push(self._align(part, width, align));
|
||||
ftor[no].push(out.length - 1);
|
||||
rtof.push(no);
|
||||
} else {
|
||||
line = line.substring(i - 1);
|
||||
out.push(self._align(part, width, align));
|
||||
ftor[no].push(out.length - 1);
|
||||
rtof.push(no);
|
||||
}
|
||||
|
||||
out.push(self._align(part, width, align));
|
||||
ftor[no].push(out.length - 1);
|
||||
rtof.push(no);
|
||||
|
||||
// Make sure we didn't wrap the line to the very end, otherwise
|
||||
// we get a pointless empty line after a newline.
|
||||
if (line === '') continue;
|
||||
}
|
||||
if (line === '') continue main;
|
||||
|
||||
// If only an escape code got cut off, at it to `part`.
|
||||
if (/^(?:\x1b[\[\d;]*m)+$/.test(line)) {
|
||||
out[out.length-1] += line;
|
||||
continue;
|
||||
// If only an escape code got cut off, at it to `part`.
|
||||
if (/^(?:\x1b[\[\d;]*m)+$/.test(line)) {
|
||||
out[out.length-1] += line;
|
||||
continue main;
|
||||
}
|
||||
}
|
||||
|
||||
out.push(self._align(line, width, align));
|
||||
|
Loading…
x
Reference in New Issue
Block a user