From 7ec9d5a967a101ff963c39ccab104802b6fd03aa Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Wed, 9 Dec 2015 10:41:50 -0800 Subject: [PATCH 1/2] Run and select below multiselect compat. --- notebook/static/notebook/js/notebook.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/notebook/static/notebook/js/notebook.js b/notebook/static/notebook/js/notebook.js index 3d9664797..16e92c6dc 100644 --- a/notebook/static/notebook/js/notebook.js +++ b/notebook/static/notebook/js/notebook.js @@ -2095,15 +2095,16 @@ define(function (require) { */ Notebook.prototype.execute_cell_and_select_below = function () { var indices = this.get_selected_cells_indices(); + var cell_index; if (indices.length > 1) { this.execute_cells(indices); - return; + cell_index = Math.max.apply(Math, indices); + } else { + var cell = this.get_selected_cell(); + cell_index = this.find_cell_index(cell); + cell.execute(); } - var cell = this.get_selected_cell(); - var cell_index = this.find_cell_index(cell); - cell.execute(); - // If we are at the end always insert a new cell and return if (cell_index === (this.ncells()-1)) { this.command_mode(); From a9b9243ebf1cef350e623483625962160b914da2 Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Thu, 10 Dec 2015 10:03:49 -0800 Subject: [PATCH 2/2] Tests --- .../tests/notebook/execute_selected_cells.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/notebook/tests/notebook/execute_selected_cells.js b/notebook/tests/notebook/execute_selected_cells.js index 927794e5f..5cb470ab3 100644 --- a/notebook/tests/notebook/execute_selected_cells.js +++ b/notebook/tests/notebook/execute_selected_cells.js @@ -148,11 +148,31 @@ casper.notebook_test(function () { this.select_cell(1, false); this.trigger_keydown('alt-enter'); - }) + }); + this.wait_for_output(0); this.wait_for_output(1); this.then(function () { assert_outputs(['x\n', 'y\n', undefined, undefined, 'c\n', 'd\n'],'run selection and insert below'); this.validate_notebook_state('run selection insert below', 'edit', 2); }); + + this.then(function(){ + this.set_cell_text(1, 'print("z")'); + this.set_cell_text(2, 'print("a")'); + + this.select_cell(1); + this.select_cell(2, false); + this.evaluate(function () { + $("#run_cell_select_below").click(); + }); + + }); + + this.wait_for_output(1); + this.wait_for_output(2); + this.then(function () { + assert_outputs(['x\n', 'z\n', 'a\n', undefined, 'c\n', 'd\n'],'run selection and select below'); + this.validate_notebook_state('run selection select below', 'command', 3); + }); });