add tests from v1.2 branch and increase split size to improve performance
This commit is contained in:
parent
b5064a4bb3
commit
de9e5226bf
2 changed files with 33 additions and 4 deletions
|
|
@ -312,11 +312,11 @@ var Document = function(text) {
|
|||
return {row: row, column: 0};
|
||||
|
||||
// Apply doesn't work for big arrays due to max call stack detection.
|
||||
// Chrome 64 bit requires threshold smaller than 32k, using a safe value of 1k.
|
||||
// Chrome 64 bit requires threshold smaller than 32k, using a safe value of 20k.
|
||||
// To circumvent that we have to break huge inserts into smaller chunks here.
|
||||
while (lines.length > 1000) {
|
||||
var end = this._insertLines(row, lines.slice(0, 1000));
|
||||
lines = lines.slice(1000);
|
||||
while (lines.length > 20000) {
|
||||
var end = this._insertLines(row, lines.slice(0, 20000));
|
||||
lines = lines.slice(20000);
|
||||
row = end.row;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -296,6 +296,35 @@ module.exports = {
|
|||
"test: empty document has to contain one line": function() {
|
||||
var doc = new Document("");
|
||||
assert.equal(doc.$lines.length, 1);
|
||||
},
|
||||
|
||||
"test: ignore empty delta": function() {
|
||||
var doc = new Document("");
|
||||
doc.on("change", function() {
|
||||
throw "should ignore empty delta";
|
||||
})
|
||||
doc.insert({row: 0, column: 0}, "");
|
||||
doc.insert({row: 1, column: 1}, "");
|
||||
doc.remove({start: {row: 1, column: 1}, end: {row: 1, column: 1}});
|
||||
},
|
||||
|
||||
"test: inserting huge delta": function() {
|
||||
var doc = new Document("");
|
||||
var val = "";
|
||||
var MAX = 0xF000;
|
||||
for (var i = 0; i < 10 * MAX; i++) {
|
||||
val += i + "\n"
|
||||
}
|
||||
doc.setValue(val);
|
||||
assert.equal(doc.getValue(), val);
|
||||
|
||||
for (var i = 3 * MAX + 2; i >= 3 * MAX - 2; i--) {
|
||||
val = doc.getLines(0, i).join("\n");
|
||||
doc.setValue("\nab");
|
||||
assert.equal(doc.getValue(), "\nab");
|
||||
doc.insert({row: 1, column: 1}, val);
|
||||
assert.equal(doc.getValue(), "\na" + val + "b");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue