From c333778a873d155b82826ab390589852cdfd5032 Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Fri, 16 Oct 2015 10:24:16 -0700 Subject: [PATCH] Use offset param instead of direction --- notebook/static/notebook/js/actions.js | 4 ++-- notebook/static/notebook/js/notebook.js | 9 +++------ notebook/tests/notebook/dualmode_merge.js | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/notebook/static/notebook/js/actions.js b/notebook/static/notebook/js/actions.js index 2d08c12f0..3a7197154 100644 --- a/notebook/static/notebook/js/actions.js +++ b/notebook/static/notebook/js/actions.js @@ -177,14 +177,14 @@ define(function(require){ help: 'extend marked above', help_index : 'dc', handler : function (env) { - env.notebook.extend_marked('up'); + env.notebook.extend_marked(1); } }, 'extend-marked-next' : { help: 'extend marked below', help_index : 'dd', handler : function (env) { - env.notebook.extend_marked('down'); + env.notebook.extend_marked(-1); } }, 'cut-selected-cell' : { diff --git a/notebook/static/notebook/js/notebook.js b/notebook/static/notebook/js/notebook.js index 11fd01d7c..523bb9570 100644 --- a/notebook/static/notebook/js/notebook.js +++ b/notebook/static/notebook/js/notebook.js @@ -716,13 +716,10 @@ define(function (require) { /** * Extend the selected range * - * @param {string} [direction='down'] - 'up' or 'down + * @param {number} offset */ - Notebook.prototype.extend_marked = function(direction) { - - // Convert the direction to an index offset - var offset = direction === 'up' ? -1 : 1; - + Notebook.prototype.extend_marked = function(offset) { + // Mark currently selected cell this.get_selected_cell().marked = true; diff --git a/notebook/tests/notebook/dualmode_merge.js b/notebook/tests/notebook/dualmode_merge.js index 18b3b407d..2a6520595 100644 --- a/notebook/tests/notebook/dualmode_merge.js +++ b/notebook/tests/notebook/dualmode_merge.js @@ -41,7 +41,7 @@ casper.notebook_test(function () { this.test.assertEquals(this.get_cell_text(1), 'cd', 'split; Verify that cell 1 has the second half.'); this.validate_notebook_state('split', 'edit', 1); this.select_cell(0); // Move up to cell 0 - this.evaluate(function() { IPython.notebook.extend_marked('down');}); + this.evaluate(function() { IPython.notebook.extend_marked(1);}); this.trigger_keydown('shift-m'); // Merge this.validate_notebook_state('merge', 'command', 0); this.test.assertEquals(this.get_cell_text(0), a, 'merge; Verify that cell 0 has the merged contents.');