From e7912c46824b9009f5c0659e5eca02a46ab533bc Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Thu, 10 Dec 2015 14:15:24 +0100 Subject: [PATCH 1/2] have shift-m merge below if one cell selected --- notebook/static/notebook/js/actions.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/notebook/static/notebook/js/actions.js b/notebook/static/notebook/js/actions.js index 55e3a985a..7aed26ed5 100644 --- a/notebook/static/notebook/js/actions.js +++ b/notebook/static/notebook/js/actions.js @@ -380,13 +380,25 @@ define(function(require){ env.notebook.merge_cell_below(); } }, - 'merge-cells' : { + 'merge-selected-cells' : { help : 'merge selected cells', help_index: 'el', handler: function(env) { env.notebook.merge_selected_cells(); } }, + 'merge-cells' : { + help : 'merge selected cells, or current cell with cell below if only one cell selected', + help_index: 'el', + handler: function(env) { + var l = env.notebook.get_selected_cells_indices().length + if(l == 1){ + env.notebook.merge_cell_below(); + } else { + env.notebook.merge_selected_cells(); + } + } + }, 'show-command-palette': { help_index : 'aa', help: 'open the command palette', From 7dd57f96963e235e9c2808765fd701b59d9f2b9f Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Thu, 10 Dec 2015 18:51:10 +0100 Subject: [PATCH 2/2] Update merge tests with new behavior (merge below) --- notebook/tests/notebook/dualmode_merge.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/notebook/tests/notebook/dualmode_merge.js b/notebook/tests/notebook/dualmode_merge.js index a10819b16..e3751951a 100644 --- a/notebook/tests/notebook/dualmode_merge.js +++ b/notebook/tests/notebook/dualmode_merge.js @@ -185,14 +185,13 @@ casper.notebook_test(function () { // shift-m on single selection does nothing. this.trigger_keydown('shift-m'); this.trigger_keydown('esc'); - this.test.assertEquals(this.get_cells_length(), N-1 , 'Merge cell 4 with 5: There are now '+(N-1)+' cells'); + this.test.assertEquals(this.get_cells_length(), N-2 , 'Merge cell 4 with 5: There are now '+(N-2)+' cells'); this.test.assertEquals(this.get_cell_text(0), a, 'Merge cell 4 with 5: Cell 0 is unchanged'); this.test.assertEquals(this.get_cell_text(1), b, 'Merge cell 4 with 5: Cell 1 is unchanged'); this.test.assertEquals(this.get_cell_text(2), c, 'Merge cell 4 with 5: Cell 2 is unchanged'); this.test.assertEquals(this.get_cell_text(3), d+'\n\n'+e, 'Merge cell 4 with 5: Cell 3 is unchanged'); - this.test.assertEquals(this.get_cell_text(4), f, 'Merge cell 4 with 5: Cell 5 is unchanged'); - this.test.assertEquals(this.get_cell_text(5), g, 'Merge cell 4 with 5: Cell 6 is unchanged'); - this.validate_notebook_state('merge on single selection does nothing', 'command', 4); + this.test.assertEquals(this.get_cell_text(4), f+'\n\n'+g, 'Merge cell 4 with 5: Cell 4 and 5 are merged'); + this.validate_notebook_state('merge on single cell merge with below', 'command', 4); });