From 11493ca042e7bbb87fe0471a1973ab6993eae942 Mon Sep 17 00:00:00 2001 From: "Brian E. Granger" Date: Wed, 8 Jan 2014 16:45:28 -0800 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. --- IPython/html/static/notebook/js/codecell.js | 8 -------- IPython/html/static/notebook/js/keyboardmanager.js | 2 ++ IPython/html/static/notebook/js/notebook.js | 5 +++++ IPython/html/static/notebook/js/textcell.js | 8 -------- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index 28162bc04..6980b5e09 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 6b46e9d83..c51f082ae 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 31e715c6c..c301950cf 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 7722ca444..4ae313511 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) {