From ddfc2ef2f4f6b0dc48383861fba561a06950c74e Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Mon, 14 Dec 2015 13:38:41 +0100 Subject: [PATCH] Make focus follow shift-selection. --- notebook/static/notebook/js/actions.js | 12 ++++++++++-- notebook/static/notebook/js/notebook.js | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/notebook/static/notebook/js/actions.js b/notebook/static/notebook/js/actions.js index 7aed26ed5..dbf610b20 100644 --- a/notebook/static/notebook/js/actions.js +++ b/notebook/static/notebook/js/actions.js @@ -183,14 +183,22 @@ define(function(require){ help: 'extend selected cells above', help_index : 'dc', handler : function (env) { - env.notebook.extend_selection_by(-1) + env.notebook.extend_selection_by(-1); + // scroll into view, + // do not call notebook.focus_cell(), or + // all the selection get thrown away + env.notebook.get_selected_cell().element.focus(); } }, 'extend-selection-below' : { help: 'extend selected cells below', help_index : 'dd', handler : function (env) { - env.notebook.extend_selection_by(1) + env.notebook.extend_selection_by(1); + // scroll into view, + // do not call notebook.focus_cell(), or + // all the selection get thrown away + env.notebook.get_selected_cell().element.focus(); } }, 'cut-cell' : { diff --git a/notebook/static/notebook/js/notebook.js b/notebook/static/notebook/js/notebook.js index 293e552e7..60af9da51 100644 --- a/notebook/static/notebook/js/notebook.js +++ b/notebook/static/notebook/js/notebook.js @@ -607,7 +607,7 @@ define(function (require) { * @return {Cell} The selected cell */ Notebook.prototype.get_selected_cell = function () { - var index = this.get_selected_cells_indices(); + var index = this.get_selected_index(); return this.get_cell(index); }; @@ -711,7 +711,7 @@ define(function (require) { this.get_cell(sindex).unselect(moveanchor); } if(moveanchor){ - this.get_cell(this.get_anchor_index()).unselect(true); + this.get_cell(this.get_anchor_index()).unselect(moveanchor); } var cell = this.get_cell(index); cell.select(moveanchor);