diff --git a/lib/ace/layer/text.js b/lib/ace/layer/text.js
index 4b6bfec7..f0e73720 100644
--- a/lib/ace/layer/text.js
+++ b/lib/ace/layer/text.js
@@ -193,8 +193,8 @@ var Text = function(parentEl) {
var first = Math.max(firstRow, config.firstRow);
var last = Math.min(lastRow, config.lastRow);
- var lineElements = this.element.childNodes,
- lineElementsIdx = 0;
+ var lineElements = this.element.childNodes;
+ var lineElementsIdx = 0;
for (var row = config.firstRow; row < first; row++) {
var foldLine = this.session.getFoldLine(row);
@@ -215,7 +215,7 @@ var Text = function(parentEl) {
var html = [];
var tokens = this.session.getTokens(i, i);
- this.$renderLine(html, i, tokens[0].tokens);
+ this.$renderLine(html, i, tokens[0].tokens, true);
lineElement = dom.setInnerHtml(lineElement, html.join(""));
i = this.session.getRowFoldEnd(i);
@@ -271,9 +271,7 @@ var Text = function(parentEl) {
if(row > lastRow)
break;
- var lineEl = dom.createElement("div");
-
- lineEl.className = "ace_line";
+ var container = dom.createElement("div");
var html = [];
// Get the tokens per line as there might be some lines in between
@@ -282,11 +280,13 @@ var Text = function(parentEl) {
// 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);
+ this.$renderLine(html, row, tokens[0].tokens, false);
// don't use setInnerHtml since we are working with an empty DIV
- lineEl.innerHTML = html.join("");
- fragment.appendChild(lineEl);
+ container.innerHTML = html.join("");
+ var lines = container.childNodes
+ while(lines.length)
+ fragment.appendChild(lines[0]);
row++;
}
@@ -313,15 +313,13 @@ var Text = function(parentEl) {
if(row > lastRow)
break;
- 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("
");
+ this.$renderLine(html, row, tokens[0].tokens, false);
row++;
}
@@ -378,7 +376,7 @@ var Text = function(parentEl) {
return screenColumn + value.length;
};
- this.$renderLineCore = function(stringBuilder, lastRow, tokens, splits) {
+ this.$renderLineCore = function(stringBuilder, lastRow, tokens, splits, onlyContents) {
var chars = 0;
var split = 0;
var splitChars;
@@ -388,7 +386,8 @@ var Text = function(parentEl) {
function addToken(token, value) {
screenColumn = self.$renderToken(
- stringBuilder, screenColumn, token, value);
+ stringBuilder, screenColumn, token, value
+ );
}
if (!splits || splits.length == 0) {
@@ -397,9 +396,13 @@ var Text = function(parentEl) {
splitChars = splits[0];
}
- stringBuilder.push("");
+ if (!onlyContents) {
+ stringBuilder.push("
"
+ );
+ }
+
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
var value = token.value;
@@ -412,10 +415,14 @@ var Text = function(parentEl) {
addToken(token, value.substring(0, splitChars - chars));
value = value.substring(splitChars - chars);
chars = splitChars;
- stringBuilder.push("
",
- "
");
+
+ if (!onlyContents) {
+ stringBuilder.push("
",
+ "
"
+ );
+ }
split ++;
screenColumn = 0;
@@ -438,18 +445,18 @@ var Text = function(parentEl) {
stringBuilder.push("
");
};
- this.$renderLine = function(stringBuilder, row, tokens) {
+ this.$renderLine = function(stringBuilder, row, tokens, onlyContents) {
// Check if the line to render is folded or not. If not, things are
// simple, otherwise, we need to fake some things...
if (!this.session.isRowFolded(row)) {
var splits = this.session.getRowSplitData(row);
- this.$renderLineCore(stringBuilder, row, tokens, splits);
+ this.$renderLineCore(stringBuilder, row, tokens, splits, onlyContents);
} else {
- this.$renderFoldLine(stringBuilder, row, tokens);
+ this.$renderFoldLine(stringBuilder, row, tokens, onlyContents);
}
};
- this.$renderFoldLine = function(stringBuilder, row, tokens) {
+ this.$renderFoldLine = function(stringBuilder, row, tokens, onlyContents) {
var session = this.session,
foldLine = session.getFoldLine(row),
renderTokens = [];
@@ -512,7 +519,7 @@ var Text = function(parentEl) {
// TODO: Build a fake splits array!
var splits = this.session.$useWrapMode?this.session.$wrapData[row]:null;
- this.$renderLineCore(stringBuilder, row, renderTokens, splits);
+ this.$renderLineCore(stringBuilder, row, renderTokens, splits, onlyContents);
};
this.destroy = function() {