From a318c447ffd4e158b3f53f66f7f2713c46e8a0b0 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Sun, 12 Apr 2020 16:24:16 +0200 Subject: [PATCH] Prevent errors when scrolling history --- js/inputbar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/inputbar.js b/js/inputbar.js index 95b710d..3380530 100644 --- a/js/inputbar.js +++ b/js/inputbar.js @@ -477,7 +477,7 @@ weechat.directive('inputBar', function() { // Arrow up -> go up in history if ($event.type === "keydown" && code === 38 && document.activeElement === inputNode) { caretPos = inputNode.selectionStart; - if ($scope.command.slice(0, caretPos).indexOf("\n") !== -1) { + if (!$scope.command || $scope.command.slice(0, caretPos).indexOf("\n") !== -1) { return false; } $scope.command = models.getActiveBuffer().getHistoryUp($scope.command); @@ -494,7 +494,7 @@ weechat.directive('inputBar', function() { // Arrow down -> go down in history if ($event.type === "keydown" && code === 40 && document.activeElement === inputNode) { caretPos = inputNode.selectionStart; - if ($scope.command.slice(caretPos).indexOf("\n") !== -1) { + if (!$scope.command || $scope.command.slice(caretPos).indexOf("\n") !== -1) { return false; } $scope.command = models.getActiveBuffer().getHistoryDown($scope.command);