fix bug in rowCache

This commit is contained in:
nightwing 2012-12-01 17:11:37 +04:00
commit fd126e06c3
2 changed files with 29 additions and 8 deletions

View file

@ -244,7 +244,7 @@ var EditSession = function(text, mode) {
return mid;
}
return low && low -1;
return low -1;
};
this.resetCaches = function() {
@ -2164,12 +2164,13 @@ var EditSession = function(text, mode) {
var rowCache = this.$screenRowCache;
var i = this.$getRowCacheIndex(rowCache, screenRow);
if (0 < i && i < rowCache.length) {
var l = rowCache.length;
if (l && i >= 0) {
var row = rowCache[i];
var docRow = this.$docRowCache[i];
var doCache = screenRow > row || (screenRow == row && i == rowCache.length - 1);
var doCache = screenRow > rowCache[l - 1];
} else {
var doCache = i != 0 || !rowCache.length;
var doCache = !l;
}
var maxRow = this.getLength() - 1;
@ -2189,6 +2190,8 @@ var EditSession = function(text, mode) {
foldStart = foldLine ? foldLine.start.row : Infinity;
}
}
// if (rowCache[rowCache.length-1] >= row)console.error("---------")
if (doCache) {
this.$docRowCache.push(docRow);
this.$screenRowCache.push(row);
@ -2269,12 +2272,13 @@ var EditSession = function(text, mode) {
var rowCache = this.$docRowCache;
var i = this.$getRowCacheIndex(rowCache, docRow);
if (0 < i && i < rowCache.length) {
var l = rowCache.length;
if (l && i >= 0) {
var row = rowCache[i];
var screenRow = this.$screenRowCache[i];
var doCache = docRow > row || (docRow == row && i == rowCache.length - 1);
var doCache = docRow > rowCache[l - 1];
} else {
var doCache = i != 0 || !rowCache.length;
var doCache = !l;
}
var foldLine = this.getNextFoldLine(row);
@ -2295,6 +2299,7 @@ var EditSession = function(text, mode) {
screenRow += this.getRowLength(row);
row = rowEnd;
// if (rowCache[rowCache.length-1] >= row)console.error("---------")
if (doCache) {
this.$docRowCache.push(row);
this.$screenRowCache.push(screenRow);