Skip to content

Commit

Permalink
Merge pull request embarklabs#5 from kylefleming/master
Browse files Browse the repository at this point in the history
Fix scroll performance for widgets with huge content
  • Loading branch information
iurimatias authored Jul 6, 2018
2 parents 302f365 + ebcb0af commit ce88e05
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/widgets/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ Element.prototype._parseAttr = function(lines) {
, j
, c;

if (lines[0].attr === attr) {
if (Array.isArray(lines.attr) && lines.attr.length > 0
&& lines.attr[0] === attr) {
return;
}

Expand Down
45 changes: 45 additions & 0 deletions test/widget-huge-content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
var blessed = require('../')
, screen;

screen = blessed.screen({
dump: __dirname + '/logs/huge-content.log',
smartCSR: true,
warnings: true
});

var content = '';
for (var j = 0; j < 2000; j++) {
for (var i = 0; i < 100; i++) {
content += 'line: ' + i + '\n';
}
for (var i = 0; i < 10000; i++) {
content += 'longline';
}
content += '\n';
}

var box = blessed.box({
parent: screen,
scrollable: true,
left: 'center',
top: 'center',
width: '80%',
height: '80%',
border: 'line',
content: content,
keys: true,
vi: true,
alwaysScroll: true,
scrollbar: {
ch: ' ',
inverse: true
}
});

screen.key('q', function() {
return screen.destroy();
});

box.focus();

screen.render();

0 comments on commit ce88e05

Please sign in to comment.