« get me outta code hell

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:
Diffstat (limited to 'ui')
-rw-r--r--ui/form/ListScrollForm.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/ui/form/ListScrollForm.js b/ui/form/ListScrollForm.js
index 300fed4..3f16416 100644
--- a/ui/form/ListScrollForm.js
+++ b/ui/form/ListScrollForm.js
@@ -62,6 +62,8 @@ module.exports = class ListScrollForm extends Form {
         item.visible = false
       }
     }
+
+    delete this._scrollItemsLength
   }
 
   keyPressed(keyBuf) {
@@ -151,8 +153,12 @@ module.exports = class ListScrollForm extends Form {
   }
 
   getScrollItemsLength() {
-    const lastInput = this.inputs[this.inputs.length - 1]
-    return this.getScrollPositionOfElementAtEndOfView(lastInput)
+    if (typeof this._scrollItemsLength === 'undefined') {
+      const lastInput = this.inputs[this.inputs.length - 1]
+      this._scrollItemsLength = this.getScrollPositionOfElementAtEndOfView(lastInput)
+    }
+
+    return this._scrollItemsLength
   }
 
   getItemPos(item) {