« get me outta code hell

Avoid crashing when scrolled past end of form - tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
path: root/ui
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-04-02 08:12:52 -0300
committerFlorrie <towerofnix@gmail.com>2019-04-02 08:12:52 -0300
commitdf0e9afe7aedd3dc6a1d0db72530a52e135af649 (patch)
tree296627e0008838d17428273ae03a02d3f210b43b /ui
parentaa38d1beb78635e5273b89b76c6a2b91428dd62c (diff)
Avoid crashing when scrolled past end of form
Usually this doesn't happen, but it may occur if the items of the
ListScrollForm are regenerated (to a lesser length) before updating
scrollItems.
Diffstat (limited to 'ui')
-rw-r--r--ui/form/ListScrollForm.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/ui/form/ListScrollForm.js b/ui/form/ListScrollForm.js
index 0e230b5..892f964 100644
--- a/ui/form/ListScrollForm.js
+++ b/ui/form/ListScrollForm.js
@@ -32,7 +32,7 @@ module.exports = class ListScrollForm extends Form {
     // we've scrolled, so we know right away that none of those will be
     // visible and we won't bother iterating over them. We do need to hide
     // them, though.
-    for (let i = 0; i < scrollItems; i++) {
+    for (let i = 0; i < Math.min(scrollItems, this.inputs.length); i++) {
       this.inputs[i].visible = false
     }