From 2730f3562d59d4d95d8f5ba93553d9d349091bec 2014-03-03 19:33:58 From: Jonathan Frederic Date: 2014-03-03 19:33:58 Subject: [PATCH] Check down too. --- diff --git a/IPython/html/static/notebook/js/keyboardmanager.js b/IPython/html/static/notebook/js/keyboardmanager.js index ccfcb62..3632669 100644 --- a/IPython/html/static/notebook/js/keyboardmanager.js +++ b/IPython/html/static/notebook/js/keyboardmanager.js @@ -163,13 +163,15 @@ var IPython = (function (IPython) { help_index : '', handler : function (event) { var index = IPython.notebook.get_selected_index(); - var cell = IPython.notebook.get_selected_cell(); - if (index !== 0 && cell && cell.at_top()) { - event.preventDefault(); - IPython.notebook.command_mode(); - IPython.notebook.select_prev(); - IPython.notebook.edit_mode(); - return false; + var cell = IPython.notebook.get_cell(index); + if (index !== null && index !== 0) { + if (cell && cell.at_top()) { + event.preventDefault(); + IPython.notebook.command_mode(); + IPython.notebook.select_prev(); + IPython.notebook.edit_mode(); + return false; + } } } }, @@ -177,13 +179,16 @@ var IPython = (function (IPython) { help : '', help_index : '', handler : function (event) { - var cell = IPython.notebook.get_selected_cell(); - if (cell && cell.at_bottom()) { - event.preventDefault(); - IPython.notebook.command_mode(); - IPython.notebook.select_next(); - IPython.notebook.edit_mode(); - return false; + var index = IPython.notebook.get_selected_index(); + var cell = IPython.notebook.get_cell(index); + if (index !== null && index !== (IPython.notebook.ncells()-1)) { + if (cell && cell.at_bottom()) { + event.preventDefault(); + IPython.notebook.command_mode(); + IPython.notebook.select_next(); + IPython.notebook.edit_mode(); + return false; + } } } },