From a14941ab7d5acb61abc3c27ba470db9f0e4ba4c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Tue, 3 Apr 2018 14:15:12 +0200 Subject: [PATCH 1/2] Don't jump to hidden buffers with Alt-A See #998 --- js/glowingbear.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 32b4193..f87b139 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -796,7 +796,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // Try to find buffer with notification for (i in sortedBuffers) { buffer = sortedBuffers[i]; - if (buffer.notification > 0) { + if (buffer.notification > 0 && !buffer.hidden) { $scope.setActiveBuffer(buffer.id); return; // return instead of break so that the second for loop isn't executed } @@ -804,7 +804,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // No notifications, find first buffer with unread lines instead for (i in sortedBuffers) { buffer = sortedBuffers[i]; - if (buffer.unread > 0) { + if (buffer.unread > 0 && !buffer.hidden) { $scope.setActiveBuffer(buffer.id); return; } From 063b91d5c230b1c5881416b0ed2ae49b251caa6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Tue, 3 Apr 2018 14:32:28 +0200 Subject: [PATCH 2/2] Don't switch to hidden buffers with Alt-Up/Down either --- js/glowingbear.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index f87b139..0bc3ca7 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -819,12 +819,18 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // direction is +1 for next buffer, -1 for previous buffer var sortedBuffers = _.sortBy($scope.getBuffers(), $rootScope.predicate); var activeBuffer = models.getActiveBuffer(); - var index = sortedBuffers.indexOf(activeBuffer); - if (index >= 0) { - var newBuffer = sortedBuffers[index + direction]; - if (newBuffer) { - $scope.setActiveBuffer(newBuffer.id); - } + var index = sortedBuffers.indexOf(activeBuffer) + direction; + var newBuffer; + + // look for next non-hidden buffer + while (index >= 0 && index < sortedBuffers.length && + (!newBuffer || newBuffer.hidden)) { + newBuffer = sortedBuffers[index]; + index += direction; + } + + if (!!newBuffer) { + $scope.setActiveBuffer(newBuffer.id); } };