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) {
|
||||
if (!docRrow) {
|
||||
this.$resetRowCache = function(docRow) {
|
||||
if (!docRow) {
|
||||
this.$docRowCache = [];
|
||||
this.$screenRowCache = [];
|
||||
return;
|
||||
}
|
||||
|
||||
var i = this.$getRowCacheIndex(this.$docRowCache, docRrow) + 1;
|
||||
var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1;
|
||||
var l = this.$docRowCache.length;
|
||||
this.$docRowCache.splice(i, l);
|
||||
this.$screenRowCache.splice(i, l);
|
||||
|
|
@ -1868,10 +1868,8 @@ var EditSession = function(text, mode) {
|
|||
};
|
||||
|
||||
this.$updateRowLengthCache = function(firstRow, lastRow, b) {
|
||||
//console.log(firstRow, lastRow, b)
|
||||
this.$rowLengthCache[firstRow] = null;
|
||||
this.$rowLengthCache[lastRow] = null;
|
||||
//console.log(this.$rowLengthCache)
|
||||
};
|
||||
|
||||
/** internal, hide
|
||||
|
|
@ -2251,7 +2249,7 @@ var EditSession = function(text, mode) {
|
|||
var docRow = this.$docRowCache[i];
|
||||
var doCache = screenRow > row || (screenRow == row && i == rowCache.length - 1);
|
||||
} else {
|
||||
var doCache = true;
|
||||
var doCache = i != 0 || !rowCache.length;
|
||||
}
|
||||
|
||||
var maxRow = this.getLength() - 1;
|
||||
|
|
@ -2356,7 +2354,7 @@ var EditSession = function(text, mode) {
|
|||
var screenRow = this.$screenRowCache[i];
|
||||
var doCache = docRow > row || (docRow == row && i == rowCache.length - 1);
|
||||
} else {
|
||||
var doCache = true;
|
||||
var doCache = i != 0 || !rowCache.length;
|
||||
}
|
||||
|
||||
var foldLine = this.getNextFoldLine(row);
|
||||
|
|
|
|||
|
|
@ -69,6 +69,13 @@ function createFoldTestSession() {
|
|||
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 = {
|
||||
|
||||
"test: find matching opening bracket in Text mode" : function() {
|
||||
|
|
@ -808,13 +815,6 @@ module.exports = {
|
|||
},
|
||||
|
||||
"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) {
|
||||
line0 && assertArray(wrapData[0], line0);
|
||||
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, 6, 0, 8));
|
||||
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