From 3c01ad1b686c0e3bdda6ec600066a57f3bdb089d Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Tue, 29 Oct 2013 12:34:16 +0100 Subject: [PATCH] Fix bug with switching to core buffer when buffer is closed --- js/models.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/js/models.js b/js/models.js index 79f5070..bb9a41b 100644 --- a/js/models.js +++ b/js/models.js @@ -361,15 +361,17 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter) /* * Closes a weechat buffer. Sets the first buffer - * as active. + * as active, if the closing buffer was active before * * @param bufferId id of the buffer to close * @return undefined */ this.closeBuffer = function(bufferId) { - + var wasActive = this.model['buffers'][bufferId.id].active; + if(wasActive) { + var firstBuffer = _.keys(this.model['buffers'])[0]; + this.setActiveBuffer(firstBuffer); + } delete(this.model['buffers'][bufferId.id]); - var firstBuffer = _.keys(this.model['buffers'])[0]; - this.setActiveBuffer(firstBuffer); } }]);