diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js index aa05f44..46bf9d3 100644 --- a/IPython/html/static/tree/js/notebooklist.js +++ b/IPython/html/static/tree/js/notebooklist.js @@ -219,6 +219,9 @@ define([ var type_order = {'directory':0,'notebook':1,'file':2}; NotebookList.prototype.draw_notebook_list = function (list, error_msg) { + // Remember what was selected before the refresh. + var selected_before = this.selected; + list.content.sort(function(a, b) { if (type_order[a['type']] < type_order[b['type']]) { return -1; @@ -265,7 +268,20 @@ define([ } // Trigger an event when we've finished drawing the notebook list. events.trigger('draw_notebook_list.NotebookList'); - this._selection_changed(); + + // Reselect the items that were selected before. Notify listeners + // that the selected items may have changed. O(n^2) operation. + selected_before.forEach(function(item) { + var list_items = $('.list_item'); + for (var i=0; i