Skip to content

Commit

Permalink
Only call CM.focus() if CM is not already focused.
Browse files Browse the repository at this point in the history
  • Loading branch information
ellisonbg committed Jan 30, 2014
1 parent b91d6a6 commit a759238
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion IPython/html/static/notebook/js/cell.js
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit a759238

Please sign in to comment.