diff --git a/demo/demo.js b/demo/demo.js index 4a59a8f7..d1bac476 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -365,14 +365,10 @@ exports.launch = function(env) { env.editor.getSession().setUseSoftTabs(checked); }); - var secondSplitSession = null; bindDropdown("split", function(value) { var sp = env.split; if (value == "none") { - if (sp.getSplits() == 2) { - secondSplitSession = sp.getEditor(1).session; - sp.setSplits(1); - } + sp.setSplits(1); } else { var newEditor = (sp.getSplits() == 1); if (value == "below") { @@ -383,7 +379,7 @@ exports.launch = function(env) { sp.setSplits(2); if (newEditor) { - var session = secondSplitSession || sp.getEditor(0).session; + var session = sp.getEditor(0).session; var newSession = sp.setSession(session, 1); newSession.name = session.name; } diff --git a/lib/ace/split.js b/lib/ace/split.js index fcbe2a14..07fa0000 100644 --- a/lib/ace/split.js +++ b/lib/ace/split.js @@ -96,6 +96,11 @@ var Split = function(container, theme, splits) { if (splits == this.$splits) { return; } else if (splits > this.$splits) { + while (this.$splits < this.$editors.length && this.$splits < splits) { + var editor = this.$editors[this.$splits]; + this.$container.appendChild(editor.container); + this.$splits ++; + } while (this.$splits < splits) { this.$createEditor(); this.$splits ++; @@ -103,9 +108,7 @@ var Split = function(container, theme, splits) { } else { while (this.$splits > splits) { editor = this.$editors[this.$splits - 1]; - editor.destroy(); this.$container.removeChild(editor.container); - this.$editors.pop(); this.$splits --; } }