Merge pull request #376 from rstudio/bugfix/wrap-mode-rendering

Bugfix/wrap mode rendering (bug 371)
This commit is contained in:
Fabian Jakobs 2011-08-12 00:30:44 -07:00
commit 620ed6ea48

View file

@ -215,7 +215,7 @@ var Text = function(parentEl) {
var html = []; var html = [];
var tokens = this.session.getTokens(i, i); var tokens = this.session.getTokens(i, i);
this.$renderLine(html, i, tokens[0].tokens, true); this.$renderLine(html, i, tokens[0].tokens, !this.$useLineGroups());
lineElement = dom.setInnerHtml(lineElement, html.join("")); lineElement = dom.setInnerHtml(lineElement, html.join(""));
i = this.session.getRowFoldEnd(i); i = this.session.getRowFoldEnd(i);
@ -284,9 +284,14 @@ var Text = function(parentEl) {
// don't use setInnerHtml since we are working with an empty DIV // don't use setInnerHtml since we are working with an empty DIV
container.innerHTML = html.join(""); container.innerHTML = html.join("");
var lines = container.childNodes if (this.$useLineGroups()) {
while(lines.length) container.className = 'ace_line_group';
fragment.appendChild(lines[0]); fragment.appendChild(container);
} else {
var lines = container.childNodes
while(lines.length)
fragment.appendChild(lines[0]);
}
row++; row++;
} }
@ -313,6 +318,9 @@ var Text = function(parentEl) {
if(row > lastRow) if(row > lastRow)
break; break;
if (this.$useLineGroups())
html.push("<div class='ace_line_group'>")
// Get the tokens per line as there might be some lines in between // Get the tokens per line as there might be some lines in between
// beeing folded. // beeing folded.
// OPTIMIZE: If there is a long block of unfolded lines, just make // OPTIMIZE: If there is a long block of unfolded lines, just make
@ -321,6 +329,9 @@ var Text = function(parentEl) {
if (tokens.length == 1) if (tokens.length == 1)
this.$renderLine(html, row, tokens[0].tokens, false); this.$renderLine(html, row, tokens[0].tokens, false);
if (this.$useLineGroups())
html.push("</div>"); // end the line group
row++; row++;
} }
this.element = dom.setInnerHtml(this.element, html.join("")); this.element = dom.setInnerHtml(this.element, html.join(""));
@ -530,6 +541,15 @@ var Text = function(parentEl) {
var splits = this.session.$useWrapMode?this.session.$wrapData[row]:null; var splits = this.session.$useWrapMode?this.session.$wrapData[row]:null;
this.$renderLineCore(stringBuilder, row, renderTokens, splits, onlyContents); this.$renderLineCore(stringBuilder, row, renderTokens, splits, onlyContents);
}; };
this.$useLineGroups = function() {
// For the updateLines function to work correctly, it's important that the
// child nodes of this.element correspond on a 1-to-1 basis to rows in the
// document (as distinct from lines on the screen). For sessions that are
// wrapped, this means we need to add a layer to the node hierarchy (tagged
// with the class name ace_line_group).
return this.session.getUseWrapMode();
};
this.destroy = function() { this.destroy = function() {
clearInterval(this.$pollSizeChangesTimer); clearInterval(this.$pollSizeChangesTimer);