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 = {