Skip to content

Commit

Permalink
Merge pull request #3126 from dwyde/arrow-keys-empty-notebook
Browse files Browse the repository at this point in the history
Prevent errors when pressing arrow keys in an empty notebook

Notebook.get_selected_cell() returns null in an empty notebook.
  • Loading branch information
minrk committed Apr 6, 2013
2 parents 9da25f6 + 5100e7d commit bea4d94
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions IPython/frontend/html/notebook/static/js/notebook.js
Expand Up @@ -137,13 +137,13 @@ var IPython = (function (IPython) {
}
if (event.which === key.UPARROW && !event.shiftKey) {
var cell = that.get_selected_cell();
if (cell.at_top()) {
if (cell && cell.at_top()) {
event.preventDefault();
that.select_prev();
};
} else if (event.which === key.DOWNARROW && !event.shiftKey) {
var cell = that.get_selected_cell();
if (cell.at_bottom()) {
if (cell && cell.at_bottom()) {
event.preventDefault();
that.select_next();
};
Expand Down Expand Up @@ -1381,7 +1381,7 @@ var IPython = (function (IPython) {
/**
* Run the selected cell.
*
* This executes code cells, and skips all others.
* Execute or render cell outputs.
*
* @method execute_selected_cell
* @param {Object} options Customize post-execution behavior
Expand Down

0 comments on commit bea4d94

Please sign in to comment.