Merge pull request #909 from ajaxorg/rowCache
fix rowcache not working for row 1
This commit is contained in:
commit
e4c8681bee
2 changed files with 40 additions and 14 deletions
|
|
@ -230,14 +230,14 @@ var EditSession = function(text, mode) {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.$resetRowCache = function(docRrow) {
|
this.$resetRowCache = function(docRow) {
|
||||||
if (!docRrow) {
|
if (!docRow) {
|
||||||
this.$docRowCache = [];
|
this.$docRowCache = [];
|
||||||
this.$screenRowCache = [];
|
this.$screenRowCache = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var i = this.$getRowCacheIndex(this.$docRowCache, docRrow) + 1;
|
var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1;
|
||||||
var l = this.$docRowCache.length;
|
var l = this.$docRowCache.length;
|
||||||
this.$docRowCache.splice(i, l);
|
this.$docRowCache.splice(i, l);
|
||||||
this.$screenRowCache.splice(i, l);
|
this.$screenRowCache.splice(i, l);
|
||||||
|
|
@ -1868,10 +1868,8 @@ var EditSession = function(text, mode) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$updateRowLengthCache = function(firstRow, lastRow, b) {
|
this.$updateRowLengthCache = function(firstRow, lastRow, b) {
|
||||||
//console.log(firstRow, lastRow, b)
|
|
||||||
this.$rowLengthCache[firstRow] = null;
|
this.$rowLengthCache[firstRow] = null;
|
||||||
this.$rowLengthCache[lastRow] = null;
|
this.$rowLengthCache[lastRow] = null;
|
||||||
//console.log(this.$rowLengthCache)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** internal, hide
|
/** internal, hide
|
||||||
|
|
@ -2251,7 +2249,7 @@ var EditSession = function(text, mode) {
|
||||||
var docRow = this.$docRowCache[i];
|
var docRow = this.$docRowCache[i];
|
||||||
var doCache = screenRow > row || (screenRow == row && i == rowCache.length - 1);
|
var doCache = screenRow > row || (screenRow == row && i == rowCache.length - 1);
|
||||||
} else {
|
} else {
|
||||||
var doCache = true;
|
var doCache = i != 0 || !rowCache.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
var maxRow = this.getLength() - 1;
|
var maxRow = this.getLength() - 1;
|
||||||
|
|
@ -2356,7 +2354,7 @@ var EditSession = function(text, mode) {
|
||||||
var screenRow = this.$screenRowCache[i];
|
var screenRow = this.$screenRowCache[i];
|
||||||
var doCache = docRow > row || (docRow == row && i == rowCache.length - 1);
|
var doCache = docRow > row || (docRow == row && i == rowCache.length - 1);
|
||||||
} else {
|
} else {
|
||||||
var doCache = true;
|
var doCache = i != 0 || !rowCache.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
var foldLine = this.getNextFoldLine(row);
|
var foldLine = this.getNextFoldLine(row);
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,13 @@ function createFoldTestSession() {
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function assertArray(a, b) {
|
||||||
|
assert.ok(a.length == b.length);
|
||||||
|
for (var i = 0; i < a.length; i++) {
|
||||||
|
assert.equal(a[i], b[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
"test: find matching opening bracket in Text mode" : function() {
|
"test: find matching opening bracket in Text mode" : function() {
|
||||||
|
|
@ -808,13 +815,6 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test fold wrap data compution": function() {
|
"test fold wrap data compution": function() {
|
||||||
function assertArray(a, b) {
|
|
||||||
assert.ok(a.length == b.length);
|
|
||||||
for (var i = 0; i < a.length; i++) {
|
|
||||||
assert.equal(a[i], b[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function assertWrap(line0, line1, line2) {
|
function assertWrap(line0, line1, line2) {
|
||||||
line0 && assertArray(wrapData[0], line0);
|
line0 && assertArray(wrapData[0], line0);
|
||||||
line1 && assertArray(wrapData[1], line1);
|
line1 && assertArray(wrapData[1], line1);
|
||||||
|
|
@ -971,6 +971,34 @@ module.exports = {
|
||||||
session.addFold("fold0", new Range(0, 1, 0, 5));
|
session.addFold("fold0", new Range(0, 1, 0, 5));
|
||||||
session.addFold("fold0", new Range(0, 6, 0, 8));
|
session.addFold("fold0", new Range(0, 6, 0, 8));
|
||||||
assert.equal(fold.subFolds.length, 2);
|
assert.equal(fold.subFolds.length, 2);
|
||||||
|
},
|
||||||
|
|
||||||
|
"test row cache": function() {
|
||||||
|
var session = createFoldTestSession();
|
||||||
|
|
||||||
|
session.screenToDocumentPosition(2,3);
|
||||||
|
assertArray(session.$docRowCache, [1,3]);
|
||||||
|
assertArray(session.$screenRowCache, [1,2]);
|
||||||
|
|
||||||
|
session.screenToDocumentPosition(5,3);
|
||||||
|
assertArray(session.$docRowCache, [1,3,4]);
|
||||||
|
assertArray(session.$screenRowCache, [1,2,3]);
|
||||||
|
|
||||||
|
session.screenToDocumentPosition(0,3);
|
||||||
|
assertArray(session.$docRowCache, [1,3,4]);
|
||||||
|
assertArray(session.$screenRowCache, [1,2,3]);
|
||||||
|
|
||||||
|
session.screenToDocumentPosition(0,0);
|
||||||
|
assertArray(session.$docRowCache, [1,3,4]);
|
||||||
|
assertArray(session.$screenRowCache, [1,2,3]);
|
||||||
|
|
||||||
|
session.screenToDocumentPosition(1,0);
|
||||||
|
assertArray(session.$docRowCache, [1,3,4]);
|
||||||
|
assertArray(session.$screenRowCache, [1,2,3]);
|
||||||
|
|
||||||
|
session.$resetRowCache();
|
||||||
|
assertArray(session.$docRowCache, []);
|
||||||
|
assertArray(session.$screenRowCache, []);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue