From 2c9404224be707c02ca94f468db12ecf4ed39861 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 8 May 2011 18:22:08 +0500 Subject: [PATCH] restore setInnerHtml optimization for text layer --- lib/ace/layer/text.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/ace/layer/text.js b/lib/ace/layer/text.js index 01ed9770..d28d34a5 100644 --- a/lib/ace/layer/text.js +++ b/lib/ace/layer/text.js @@ -286,12 +286,24 @@ var Text = function(parentEl) { this.config = config; var html = []; - var tokens = this.session.getTokens(config.firstRow, config.lastRow) - var fragment = this.$renderLinesFragment(config, config.firstRow, config.lastRow); + var firstRow = config.firstRow, lastRow = config.lastRow; + var tokens = this.session.getTokens(firstRow, lastRow) - // Clear the current content of the element and add the rendered fragment. - this.element.innerHTML = ""; - this.element.appendChild(fragment); + for (var row=firstRow; row<=lastRow; row++) { + html.push("
" + ) + // Get the tokens per line as there might be some lines in between + // beeing folded. + // OPTIMIZE: If there is a long block of unfolded lines, just make + // this call once for that big block of unfolded lines. + var tokens = this.session.getTokens(row, row); + if (tokens.length == 1) + this.$renderLine(html, row, tokens[0].tokens); + html.push("
") + row = this.session.getRowFoldEnd(row); + } + this.element = dom.setInnerHtml(this.element, html.join("")); }; this.$textToken = {