max stack size on chrome is smaller now
This commit is contained in:
parent
60dd224d96
commit
56cb246c78
1 changed files with 8 additions and 8 deletions
|
|
@ -571,11 +571,12 @@ var Document = function(textOrLines) {
|
||||||
var isInsert = delta.action == "insert";
|
var isInsert = delta.action == "insert";
|
||||||
// An empty range is a NOOP.
|
// An empty range is a NOOP.
|
||||||
if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
|
if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
|
||||||
: !Range.comparePoints(delta.start, delta.end))
|
: !Range.comparePoints(delta.start, delta.end)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isInsert && delta.lines.length > 0xF000)
|
if (isInsert && delta.lines.length > 20000)
|
||||||
this.$splitAndapplyLargeDelta(delta, 0xF000);
|
this.$splitAndapplyLargeDelta(delta, 20000);
|
||||||
|
|
||||||
// Apply.
|
// Apply.
|
||||||
applyDelta(this.$lines, delta, doNotValidate);
|
applyDelta(this.$lines, delta, doNotValidate);
|
||||||
|
|
@ -585,8 +586,8 @@ var Document = function(textOrLines) {
|
||||||
this.$splitAndapplyLargeDelta = function(delta, MAX) {
|
this.$splitAndapplyLargeDelta = function(delta, MAX) {
|
||||||
// Split large insert deltas. This is necessary because:
|
// Split large insert deltas. This is necessary because:
|
||||||
// 1. We need to support splicing delta lines into the document via $lines.splice.apply(...)
|
// 1. We need to support splicing delta lines into the document via $lines.splice.apply(...)
|
||||||
// 2. fn.apply() doesn't work for a large number of params. The smallest threshold is on safari 0xFFFF.
|
// 2. fn.apply() doesn't work for a large number of params. The smallest threshold is on chrome 40 ~42000.
|
||||||
// we use 0xF000 to leave some space for actual stack
|
// we use 20000 to leave some space for actual stack
|
||||||
//
|
//
|
||||||
// To Do: Ideally we'd be consistent and also split 'delete' deltas. We don't do this now, because delete
|
// To Do: Ideally we'd be consistent and also split 'delete' deltas. We don't do this now, because delete
|
||||||
// delta handling is too slow. If we make delete delta handling faster we can split all large deltas
|
// delta handling is too slow. If we make delete delta handling faster we can split all large deltas
|
||||||
|
|
@ -623,10 +624,9 @@ var Document = function(textOrLines) {
|
||||||
* @param {Object} delta A delta object (can include "insert" and "remove" actions)
|
* @param {Object} delta A delta object (can include "insert" and "remove" actions)
|
||||||
**/
|
**/
|
||||||
this.revertDelta = function(delta) {
|
this.revertDelta = function(delta) {
|
||||||
var range = Range.fromPoints(delta.start, delta.end);
|
|
||||||
this.applyDelta({
|
this.applyDelta({
|
||||||
start: range.start,
|
start: this.clonePos(delta.start),
|
||||||
end: range.end,
|
end: this.clonePos(delta.end),
|
||||||
action: (delta.action == "insert" ? "remove" : "insert"),
|
action: (delta.action == "insert" ? "remove" : "insert"),
|
||||||
lines: delta.lines.slice()
|
lines: delta.lines.slice()
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue