Skip to content

Commit

Permalink
Fix shift-enter behvaior in nbagg backend
Browse files Browse the repository at this point in the history
Commit 86ac6ce undid the changes from commit d527799 to change the behavior of shift-enter in Jupyter notebook, as discussed in matplotlib#1124, matplotlib#4758, and matplotlib#6752.

With the changes here, shift-enter now selects the next cell, executes it, and then selects the following cell.
  • Loading branch information
physinet committed Oct 31, 2018
1 parent d0deb47 commit 1740970
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/matplotlib/backends/web_backend/js/nbagg_mpl.js
Expand Up @@ -167,11 +167,13 @@ mpl.figure.prototype._key_event_extra = function(event, name) {
if (event.shiftKey && event.which == 13) {
this.canvas_div.blur();
event.shiftKey = false;
// Send a "J" for go to next cell
event.which = 74;
event.keyCode = 74;
manager.command_mode();
manager.handle_keydown(event);
// select the cell after this one
var index = IPython.notebook.find_cell_index(this.cell_info[0]);
IPython.notebook.select(index + 1);
// execute the cell and select the next cell
var cell = IPython.notebook.get_selected_cell();
cell.execute(true);
IPython.notebook.select(index + 2);
}
}

Expand Down

0 comments on commit 1740970

Please sign in to comment.