Fix bug in updateWrapData. Rendering still sometimes misaligned

This commit is contained in:
Julian Viereck 2011-04-28 13:57:12 +02:00
commit 353c6a4f4a
4 changed files with 28 additions and 17 deletions

View file

@ -21,6 +21,7 @@
* Contributor(s): * Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org> * Fabian Jakobs <fabian AT ajax DOT org>
* Kevin Dangoor (kdangoor@mozilla.com) * Kevin Dangoor (kdangoor@mozilla.com)
* Julian Viereck <julian DOT viereck AT gmail DOT com>
* *
* Alternatively, the contents of this file may be used under the terms of * Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or * either the GNU General Public License Version 2 or later (the "GPL"), or
@ -154,6 +155,8 @@ exports.launch = function(env) {
docs.js.addFold(new Range(1, 10, 2, 10), "foo..."); docs.js.addFold(new Range(1, 10, 2, 10), "foo...");
docs.svg.addFold(new Range(1, 0, 7, 0), "fold..."); docs.svg.addFold(new Range(1, 0, 7, 0), "fold...");
docs.plain.addFold(new Range(0, 90, 2, 30), "fold");
window.s = docs.js; window.s = docs.js;
window.e = env.editor; window.e = env.editor;
setTimeout(function() { setTimeout(function() {

View file

@ -14,6 +14,7 @@
<td align="right"> <td align="right">
<label for="doc">Document:</label> <label for="doc">Document:</label>
<select id="doc" size="1"> <select id="doc" size="1">
<option value="plain">Text Document</option>
<option value="svg">SVG Document</option> <option value="svg">SVG Document</option>
<option value="js">JavaScript Document</option> <option value="js">JavaScript Document</option>
<option value="html">HTML Document</option> <option value="html">HTML Document</option>
@ -28,7 +29,6 @@
<option value="c_cpp">C++ Document</option> <option value="c_cpp">C++ Document</option>
<option value="textile">Textile Document</option> <option value="textile">Textile Document</option>
<option value="plain">Text Document</option>
</select> </select>
</td> </td>
<td align="right"> <td align="right">

View file

@ -1005,30 +1005,38 @@ var EditSession = function(text, mode) {
var tokens; var tokens;
var foldLine; var foldLine;
for (var row = firstRow; row <= lastRow; row++) { var row = firstRow;
while (row <= lastRow) {
foldLine = this.getFoldLine(row); foldLine = this.getFoldLine(row);
if (!foldLine) { if (!foldLine) {
tokens = this.$getDisplayTokens(lang.stringTrimRight(lines[row])); tokens = this.$getDisplayTokens(lang.stringTrimRight(lines[row]));
} else { } else {
tokens = []; tokens = [];
foldLine.walk(function(placeholder, row, column, lastColumn) { foldLine.walk(
var walkTokens; function(placeholder, row, column, lastColumn) {
if (placeholder) { var walkTokens;
walkTokens = this.$getDisplayTokens(placeholder, tokens.length); if (placeholder) {
walkTokens[0] = PLACEHOLDER_START; walkTokens = this.$getDisplayTokens(
for (var i = 1; i < walkTokens.length; i++) { placeholder, tokens.length);
walkTokens[i] = PLACEHOLDER_BODY; walkTokens[0] = PLACEHOLDER_START;
for (var i = 1; i < walkTokens.length; i++) {
walkTokens[i] = PLACEHOLDER_BODY;
}
} else {
walkTokens = this.$getDisplayTokens(
lines[row].substring(lastColumn, column),
tokens.length);
} }
} else { tokens = tokens.concat(walkTokens);
walkTokens = this.$getDisplayTokens( }.bind(this),
lines[row].substring(lastColumn, column), foldLine.end.row,
tokens.length); lines[foldLine.end.row].length
} );
tokens = tokens.concat(walkTokens);
}.bind(this), row, lines[row].length);
} }
wrapData[row] = wrapData[row] =
this.$computeWrapSplits(tokens, wrapLimit, tabSize); this.$computeWrapSplits(tokens, wrapLimit, tabSize);
row = this.getRowFoldEnd(row) + 1;
} }
}; };

View file

@ -501,7 +501,7 @@ var VirtualRenderer = function(container, theme) {
}; };
// For debugging. // For debugging.
// console.log(JSON.stringify(layerConfig)); console.log(JSON.stringify(layerConfig));
this.$gutterLayer.element.style.marginTop = (-offset) + "px"; this.$gutterLayer.element.style.marginTop = (-offset) + "px";
this.content.style.marginTop = (-offset) + "px"; this.content.style.marginTop = (-offset) + "px";