Skip to content
This repository

Prevent errors when pressing arrow keys in an empty notebook #3126

Merged
merged 2 commits into from about 1 year ago

2 participants

David Wyde Min RK
David Wyde
dwyde commented April 02, 2013

Notebook.get_selected_cell() returns null in an empty notebook.

As a bonus, there's a CasperJS test in #3125.

Min RK minrk merged commit bea4d94 into from April 06, 2013
Min RK minrk closed this April 06, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Apr 02, 2013
David Wyde Prevent errors when up/down arrows are pressed in an empty notebook.
Notebook.get_selected_cell() returns `null` in an empty notebook.
9ef57ef
David Wyde Fix an incorrect comment. 5100e7d
This page is out of date. Refresh to see the latest.
6  IPython/frontend/html/notebook/static/js/notebook.js
@@ -137,13 +137,13 @@ var IPython = (function (IPython) {
137 137
             }
138 138
             if (event.which === key.UPARROW && !event.shiftKey) {
139 139
                 var cell = that.get_selected_cell();
140  
-                if (cell.at_top()) {
  140
+                if (cell && cell.at_top()) {
141 141
                     event.preventDefault();
142 142
                     that.select_prev();
143 143
                 };
144 144
             } else if (event.which === key.DOWNARROW && !event.shiftKey) {
145 145
                 var cell = that.get_selected_cell();
146  
-                if (cell.at_bottom()) {
  146
+                if (cell && cell.at_bottom()) {
147 147
                     event.preventDefault();
148 148
                     that.select_next();
149 149
                 };
@@ -1381,7 +1381,7 @@ var IPython = (function (IPython) {
1381 1381
     /**
1382 1382
      * Run the selected cell.
1383 1383
      * 
1384  
-     * This executes code cells, and skips all others.
  1384
+     * Execute or render cell outputs.
1385 1385
      * 
1386 1386
      * @method execute_selected_cell
1387 1387
      * @param {Object} options Customize post-execution behavior
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.