From 54b48d95c258b21f45259c35b7f58ddf01d8c6aa 2014-01-09 00:45:28 From: Brian E. Granger Date: 2014-01-09 00:45:28 Subject: [PATCH] Don't always call focus_cell in Cell.command_mode. The focus_cell should only be called when a user enters command mode by pressing ESC. Calling focus_cell was causing jumps when command mode was entered through a mouse click. --- diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index 28162bc..6980b5e 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -368,14 +368,6 @@ var IPython = (function (IPython) { return false; }; - CodeCell.prototype.command_mode = function () { - var cont = IPython.Cell.prototype.command_mode.apply(this); - if (cont) { - this.focus_cell(); - }; - return cont; - } - CodeCell.prototype.edit_mode = function () { var cont = IPython.Cell.prototype.edit_mode.apply(this); if (cont) { diff --git a/IPython/html/static/notebook/js/keyboardmanager.js b/IPython/html/static/notebook/js/keyboardmanager.js index 6b46e9d..c51f082 100644 --- a/IPython/html/static/notebook/js/keyboardmanager.js +++ b/IPython/html/static/notebook/js/keyboardmanager.js @@ -131,6 +131,7 @@ var IPython = (function (IPython) { help : 'command mode', handler : function (event) { IPython.notebook.command_mode(); + IPython.notebook.focus_cell(); return false; } }, @@ -138,6 +139,7 @@ var IPython = (function (IPython) { help : 'command mode', handler : function (event) { IPython.notebook.command_mode(); + IPython.notebook.focus_cell(); return false; } }, diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index 31e715c..c301950 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -547,6 +547,11 @@ var IPython = (function (IPython) { }; }; + Notebook.prototype.focus_cell = function () { + var cell = this.get_selected_cell(); + if (cell === null) {return;} // No cell is selected + cell.focus_cell(); + }; // Cell movement diff --git a/IPython/html/static/notebook/js/textcell.js b/IPython/html/static/notebook/js/textcell.js index 7722ca4..4ae3135 100644 --- a/IPython/html/static/notebook/js/textcell.js +++ b/IPython/html/static/notebook/js/textcell.js @@ -204,14 +204,6 @@ var IPython = (function (IPython) { this.render(); }; - TextCell.prototype.command_mode = function () { - var cont = IPython.Cell.prototype.command_mode.apply(this); - if (cont) { - this.focus_cell(); - }; - return cont; - } - TextCell.prototype.edit_mode = function () { var cont = IPython.Cell.prototype.edit_mode.apply(this); if (cont) {