From 4f06e21070f584ef56b40c6f195041489fe89f1e Mon Sep 17 00:00:00 2001 From: Julian Viereck Date: Fri, 20 May 2011 23:37:27 +0200 Subject: [PATCH] Reuse the editor instance in Split. Don't like that, but as the Editor is not destroyed completly, this is the base thing to do at the moment in case of memoery usage --- demo/demo.js | 8 ++------ lib/ace/split.js | 7 +++++-- 2 files changed, 7 insertions(+), 8 deletions(-) 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 --; } }