From 5455aef679bb22f7c2d965070aa5ff623f9d6c47 Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Wed, 9 Dec 2015 10:45:28 -0800 Subject: [PATCH 1/2] Run and insert 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 14c8b42aa..62c26652f 100644 --- a/notebook/static/notebook/js/notebook.js +++ b/notebook/static/notebook/js/notebook.js @@ -1969,15 +1969,16 @@ define(function (require) { */ Notebook.prototype.execute_cell_and_insert_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 4719f957ad96ff9c7b61f5d2398c6d95f7ed2b51 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Thu, 10 Dec 2015 12:42:11 +0100 Subject: [PATCH 2/2] Write test to test for running of multiple selection and insert below. --- .../tests/notebook/execute_selected_cells.js | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/notebook/tests/notebook/execute_selected_cells.js b/notebook/tests/notebook/execute_selected_cells.js index 67119f397..927794e5f 100644 --- a/notebook/tests/notebook/execute_selected_cells.js +++ b/notebook/tests/notebook/execute_selected_cells.js @@ -13,8 +13,8 @@ casper.notebook_test(function () { } else { msg = msg_prefix + 'cell ' + i + ' executed'; - var out = that.get_output_cell(i, undefined, msg_prefix).text - that.test.assertEquals(out, expected[i], msg + 'out is: '+out); + var out = (that.get_output_cell(i, undefined, msg_prefix)||{test:''}).text + that.test.assertEquals(out, expected[i], msg + ', out is: '+out); } } }; @@ -139,4 +139,20 @@ casper.notebook_test(function () { assert_outputs(['a\n', 'b\n', undefined, 'c\n', 'd\n'],'run all cells'); this.validate_notebook_state('run all cells', 'command', 4); }); + + this.then(function(){ + this.set_cell_text(0, 'print("x")'); + this.set_cell_text(1, 'print("y")'); + + this.select_cell(0); + 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); + }); });