diff --git a/edit.js b/edit.js index 40a3ec54..b79cc315 100644 --- a/edit.js +++ b/edit.js @@ -216,10 +216,11 @@ function addSection(event, section) { } else { sections.appendChild(div); } - var cm = setupCodeMirror(div.querySelector('.code')); + setupCodeMirror(div.querySelector('.code')); if (section) { var index = Array.prototype.indexOf.call(sections.children, section); - editors.splice(index, 0, editors.pop()); + var cm = editors.pop(); + editors.splice(index, 0, cm); cm.focus(); } }