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', 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); });