Only call CM.focus() if CM is not already focused.

This commit is contained in:
Brian E. Granger 2014-01-29 11:46:18 -08:00
parent fa0d5b2f1a
commit 5f4d4017c1

View File

@ -288,8 +288,16 @@ var IPython = (function (IPython) {
* @method focus_editor
*/
Cell.prototype.focus_editor = function () {
var that = this;
this.refresh();
this.code_mirror.focus();
// Only focus the CM editor if it is not focused already. This prevents jumps
// related to the previous prompt position.
setTimeout(function () {
var isf = IPython.utils.is_focused;
if (!isf(that.element.find('div.CodeMirror'))) {
this.code_mirror.focus();
}
}, 1);
}
/**