diff --git a/index.html b/index.html
index d45d339..8f7f5fe 100644
--- a/index.html
+++ b/index.html
@@ -281,7 +281,7 @@ npm run build-electron-{windows, darwin, linux}
'channel_plus': buffer.prefix === '+',
'channel_ampersand': buffer.prefix === '&',
'private': buffer.type === 'private'}"
- ng-repeat="(key, buffer) in (filteredBuffers = (getBuffers() | toArray:'withidx' | filter:{fullName:search} | filter:hasUnread | orderBy:predicate | getBufferQuickKeys:this))">
+ ng-repeat="(key, buffer) in (filteredBuffers = (getBuffers() | toArray:'withidx' | filter:bufferlistfilter | filter:hasUnread | orderBy:predicate | getBufferQuickKeys:this))">
{{ buffer.$quickKey }}
diff --git a/js/filters.js b/js/filters.js
index 6598258..3e98d6a 100644
--- a/js/filters.js
+++ b/js/filters.js
@@ -141,7 +141,6 @@ weechat.filter('getBufferQuickKeys', function () {
if (($scope.search !== undefined && $scope.search.length) || $scope.onlyUnread) {
obj.forEach(function(buf, idx) {
buf.$quickKey = idx < 10 ? (idx + 1) % 10 : '';
- buf.$jumpKey = idx + 1;
});
} else {
_.map(obj, function(buffer, idx) {
@@ -152,7 +151,11 @@ weechat.filter('getBufferQuickKeys', function () {
return left[0] - right[0] || left[1] - right[1];
}).forEach(function(info, keyIdx) {
obj[ info[2] ].$quickKey = keyIdx < 10 ? (keyIdx + 1) % 10 : '';
- obj[ info[2] ].$jumpKey = keyIdx + 1;
+ // Don't update jump key upon filtering
+ if (obj[ info[2] ].$jumpKey === undefined) {
+ // Only assign jump keys up to 99
+ obj[ info[2] ].$jumpKey = (keyIdx < 99) ? keyIdx + 1 : '';
+ }
});
}
return obj;
diff --git a/js/glowingbear.js b/js/glowingbear.js
index 38aea50..305817a 100644
--- a/js/glowingbear.js
+++ b/js/glowingbear.js
@@ -359,9 +359,20 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
};
// Watch model and update channel sorting when it changes
- settings.addCallback('orderbyserver', function(orderbyserver) {
- $rootScope.predicate = orderbyserver ? 'serverSortKey' : 'number';
- });
+ var set_filter_predicate = function(orderbyserver) {
+ if ($rootScope.showJumpKeys) {
+ $rootScope.predicate = '$jumpKey';
+ } else if (orderbyserver) {
+ $rootScope.predicate = 'serverSortKey';
+ } else {
+ $rootScope.predicate = 'number';
+ }
+ };
+ settings.addCallback('orderbyserver', set_filter_predicate);
+ // convenience wrapper for jump keys
+ $rootScope.refresh_filter_predicate = function() {
+ set_filter_predicate(settings.orderbyserver);
+ };
settings.addCallback('useFavico', function(useFavico) {
// this check is necessary as this is called on page load, too
@@ -658,6 +669,25 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
return !buffer.hidden;
};
+ // filter bufferlist for search or jump key
+ $rootScope.bufferlistfilter = function(buffer) {
+ if ($rootScope.showJumpKeys) {
+ // filter by jump key
+ if ($rootScope.jumpDecimal === undefined) {
+ // no digit input yet, show all buffers
+ return true;
+ } else {
+ var min_jumpKey = 10 * $rootScope.jumpDecimal,
+ max_jumpKey = 10 * ($rootScope.jumpDecimal + 1);
+ return (min_jumpKey <= buffer.$jumpKey) &&
+ (buffer.$jumpKey < max_jumpKey);
+ }
+ } else {
+ // filter by buffer name
+ return buffer.fullName.indexOf($scope.search) !== -1;
+ }
+ };
+
// Watch model and update show setting when it changes
settings.addCallback('nonicklist', function() {
$scope.showNicklist = $scope.updateShowNicklist();
diff --git a/js/inputbar.js b/js/inputbar.js
index ac22357..8a0de77 100644
--- a/js/inputbar.js
+++ b/js/inputbar.js
@@ -253,24 +253,32 @@ weechat.directive('inputBar', function() {
// if Alt+J was pressed last...
if ($rootScope.showJumpKeys) {
+ var cleanup = function() { // cleanup helper
+ $rootScope.showJumpKeys = false;
+ $rootScope.jumpDecimal = undefined;
+ $scope.$parent.search = '';
+ $rootScope.refresh_filter_predicate();
+ };
+
// ... we expect two digits now
if (!$event.altKey && (code > 47 && code < 58)) {
// first digit
- if ($scope.jumpDecimal === undefined) {
- $scope.jumpDecimal = code - 48;
+ if ($rootScope.jumpDecimal === undefined) {
+ $rootScope.jumpDecimal = code - 48;
$event.preventDefault();
- // second digit
+ $scope.$parent.search = $rootScope.jumpDecimal;
+ $rootScope.refresh_filter_predicate();
+ // second digit, jump to correct buffer
} else {
bufferNumber = ($rootScope.jumpDecimal * 10) + (code - 48);
$scope.$parent.setActiveBuffer(bufferNumber, '$jumpKey');
$event.preventDefault();
- $rootScope.showJumpKeys = false;
- $scope.jumpDecimal = undefined;
+ cleanup();
}
} else {
- $rootScope.showJumpKeys = false;
- $scope.jumpDecimal = undefined;
+ // Not a decimal digit, abort
+ cleanup();
}
}