From 75a3052c0763d82df555a3aa822666ae69885bbe Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Thu, 15 Oct 2015 09:52:41 -0700 Subject: [PATCH] Implement extend marked --- notebook/static/notebook/js/notebook.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/notebook/static/notebook/js/notebook.js b/notebook/static/notebook/js/notebook.js index ef0118502..11fd01d7c 100644 --- a/notebook/static/notebook/js/notebook.js +++ b/notebook/static/notebook/js/notebook.js @@ -716,10 +716,21 @@ define(function (require) { /** * Extend the selected range * - * @param {string} direction - 'up' or 'down + * @param {string} [direction='down'] - 'up' or 'down */ Notebook.prototype.extend_marked = function(direction) { - // TODO: Marked + + // Convert the direction to an index offset + var offset = direction === 'up' ? -1 : 1; + + // Mark currently selected cell + this.get_selected_cell().marked = true; + + // Select the cell in the offset direction. Bound index between 0 and + // the number of cells -1. + var selectedIndex = Math.min(Math.max(this.get_selected_index() + offset, 0), this.ncells()-1); + this.select(selectedIndex); + this.get_selected_cell().marked = true; }; // Cell selection.