fix rendering of wrapped foldlines

This commit is contained in:
nightwing 2011-11-17 20:55:54 +04:00
commit a931d239d7
2 changed files with 34 additions and 29 deletions

View file

@ -1061,9 +1061,11 @@ var EditSession = function(text, mode) {
var row = firstRow;
lastRow = Math.min(lastRow, lines.length - 1);
while (row <= lastRow) {
foldLine = this.getFoldLine(row);
foldLine = this.getFoldLine(row, foldLine);
if (!foldLine) {
tokens = this.$getDisplayTokens(lang.stringTrimRight(lines[row]));
wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
row ++;
} else {
tokens = [];
foldLine.walk(
@ -1087,16 +1089,13 @@ var EditSession = function(text, mode) {
lines[foldLine.end.row].length + 1
);
// Remove spaces/tabs from the back of the token array.
while (tokens.length != 0
&& tokens[tokens.length - 1] >= SPACE)
{
while (tokens.length != 0 && tokens[tokens.length - 1] >= SPACE)
tokens.pop();
}
}
wrapData[row] =
this.$computeWrapSplits(tokens, wrapLimit, tabSize);
row = this.getRowFoldEnd(row) + 1;
wrapData[foldLine.start.row]
= this.$computeWrapSplits(tokens, wrapLimit, tabSize);
row = foldLine.end.row + 1;
}
}
};
@ -1414,18 +1413,18 @@ var EditSession = function(text, mode) {
}
}
if (foldLine && foldLine.start.row <= docRow)
if (foldLine && foldLine.start.row <= docRow) {
line = this.getFoldDisplayLine(foldLine);
else {
docRow = foldLine.start.row;
} else {
line = this.getLine(docRow);
foldLine = null;
}
var splits = [];
if (this.$useWrapMode) {
splits = this.$wrapData[docRow];
var splits = this.$wrapData[docRow];
if (splits) {
column = splits[screenRow - row]
column = splits[screenRow - row];
if(screenRow > row && splits.length) {
docColumn = splits[screenRow - row - 1] || splits[splits.length - 1];
line = line.substring(docColumn);
@ -1436,7 +1435,7 @@ var EditSession = function(text, mode) {
docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
// clip row at the end of the document
if (row + splits.length < screenRow)
if (docRow > maxRow)
docColumn = Number.MAX_VALUE;
// Need to do some clamping action here.
@ -1577,24 +1576,29 @@ var EditSession = function(text, mode) {
this.getScreenLength = function() {
var screenRows = 0;
var lastFoldLine = null;
var foldLine = null;
var fold = null;
if (!this.$useWrapMode) {
screenRows = this.getLength();
// Remove the folded lines again.
var foldData = this.$foldData;
for (var i = 0; i < foldData.length; i++) {
foldLine = foldData[i];
screenRows -= foldLine.end.row - foldLine.start.row;
fold = foldData[i];
screenRows -= fold.end.row - fold.start.row;
}
} else {
for (var row = 0; row < this.$wrapData.length; row++) {
if (foldLine = this.getFoldLine(row, lastFoldLine)) {
row = foldLine.end.row;
screenRows += 1;
} else {
screenRows += this.$wrapData[row].length + 1;
var lastRow = this.$wrapData.length;
var row = 0, i = 0;
var fold = this.$foldData[i++];
var foldStart = fold ? fold.start.row :Infinity;
while (row < lastRow) {
screenRows += this.$wrapData[row].length + 1;
row ++;
if (row > foldStart) {
row = fold.end.row+1;
fold = this.$foldData[i++];
foldStart = fold ?fold.start.row :Infinity;
}
}
}

View file

@ -201,6 +201,7 @@ var Text = function(parentEl) {
var foldLine = this.session.getFoldLine(row);
if (foldLine) {
if (foldLine.containsRow(first)) {
first = foldLine.start.row;
break;
} else {
row = foldLine.end.row;
@ -264,12 +265,12 @@ var Text = function(parentEl) {
foldStart = fold ?fold.start.row :Infinity;
while (true) {
if(row > foldStart) {
if (row > foldStart) {
row = fold.end.row+1;
fold = this.session.getNextFoldLine(row, fold);
foldStart = fold ?fold.start.row :Infinity;
}
if(row > lastRow)
if (row > lastRow)
break;
var container = dom.createElement("div");
@ -311,12 +312,12 @@ var Text = function(parentEl) {
foldStart = fold ?fold.start.row :Infinity;
while (true) {
if(row > foldStart) {
if (row > foldStart) {
row = fold.end.row+1;
fold = this.session.getNextFoldLine(row, fold);
foldStart = fold ?fold.start.row :Infinity;
}
if(row > lastRow)
if (row > lastRow)
break;
if (this.$useLineGroups())