From 3997769defff4ae3041827497d5a8ada4662de80 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sat, 27 Sep 2014 15:57:01 -0400 Subject: [PATCH] Fixed off by one error in get_prev_cell Not sure why this was a TODO. Maybe `find_cell_index()` returned zero at one time, but in the browsers I tested, it always returns null if not found. --- IPython/html/static/notebook/js/notebook.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index ac8b220a3..522216881 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -465,11 +465,9 @@ define([ * @return {Cell} The previous cell */ Notebook.prototype.get_prev_cell = function (cell) { - // TODO: off-by-one - // nb.get_prev_cell(nb.get_cell(1)) is null var result = null; var index = this.find_cell_index(cell); - if (index !== null && index > 1) { + if (index !== null && index > 0) { result = this.get_cell(index-1); } return result;