From 97b17cf9ec7f4dca57f12d7cdacf8ac41130c686 Mon Sep 17 00:00:00 2001 From: Kyle Fleming Date: Sat, 1 Jul 2017 14:50:01 -0700 Subject: [PATCH 1/2] Add test for widget with huge content --- test/widget-huge-content.js | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/widget-huge-content.js diff --git a/test/widget-huge-content.js b/test/widget-huge-content.js new file mode 100644 index 0000000..cc9d21d --- /dev/null +++ b/test/widget-huge-content.js @@ -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(); From ebcb0af56dfccd38f539c462b46f489a374a5ed0 Mon Sep 17 00:00:00 2001 From: Kyle Fleming Date: Sat, 1 Jul 2017 14:51:32 -0700 Subject: [PATCH 2/2] Fix scroll performance for widget with huge content --- lib/widgets/element.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/widgets/element.js b/lib/widgets/element.js index 29a783c..d044ecc 100644 --- a/lib/widgets/element.js +++ b/lib/widgets/element.js @@ -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; }