apply arguments max length also includes actual call stack
This commit is contained in:
parent
6b60bcbbd6
commit
27b6d6dcd3
2 changed files with 26 additions and 21 deletions
|
|
@ -302,9 +302,11 @@ var Document = function(textOrLines) {
|
|||
row = 0;
|
||||
} else if (row >= length) {
|
||||
row = length - 1;
|
||||
column = undefined
|
||||
}
|
||||
column = undefined;
|
||||
}
|
||||
var line = this.getLine(row);
|
||||
if (column == undefined)
|
||||
column = line.length;
|
||||
column = Math.min(Math.max(column, 0), line.length);
|
||||
return {row: row, column: column};
|
||||
};
|
||||
|
|
@ -421,31 +423,33 @@ var Document = function(textOrLines) {
|
|||
**/
|
||||
this.remove = function(range) {
|
||||
var start = this.clippedPos(range.start.row, range.start.column);
|
||||
var end = this.clippedPos(range.end.row, range.end.column);
|
||||
this.applyDelta({
|
||||
action: "remove",
|
||||
start: start,
|
||||
end: this.clippedPos(range.end.row, range.end.column),
|
||||
lines: this.getLinesForRange(range),
|
||||
end: end,
|
||||
lines: this.getLinesForRange({start: start, end: end}),
|
||||
});
|
||||
return this.clonePos(start);
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes the specified columns from the `row`. This method also triggers the `"change"` event.
|
||||
* @param {Number} row The row to remove from
|
||||
* @param {Number} startColumn The column to start removing at
|
||||
* @param {Number} endColumn The column to stop removing at
|
||||
* @returns {Object} Returns an object containing `startRow` and `startColumn`, indicating the new row and column values.<br/>If `startColumn` is equal to `endColumn`, this function returns nothing.
|
||||
*
|
||||
**/
|
||||
* Removes the specified columns from the `row`. This method also triggers a `"change"` event.
|
||||
* @param {Number} row The row to remove from
|
||||
* @param {Number} startColumn The column to start removing at
|
||||
* @param {Number} endColumn The column to stop removing at
|
||||
* @returns {Object} Returns an object containing `startRow` and `startColumn`, indicating the new row and column values.<br/>If `startColumn` is equal to `endColumn`, this function returns nothing.
|
||||
*
|
||||
**/
|
||||
this.removeInLine = function(row, startColumn, endColumn) {
|
||||
var start = this.clippedPos(row, startColumn);
|
||||
var start = this.clippedPos(row, startColumn);
|
||||
var end = this.clippedPos(row, endColumn);
|
||||
|
||||
this.applyDelta({
|
||||
action: "remove",
|
||||
start: start,
|
||||
end: this.clippedPos(row, endColumn),
|
||||
lines: this.getLinesForRange(range),
|
||||
end: end,
|
||||
lines: this.getLinesForRange({start: start, end: end}),
|
||||
}, true);
|
||||
|
||||
return this.clonePos(start);
|
||||
|
|
@ -568,7 +572,7 @@ var Document = function(textOrLines) {
|
|||
: !Range.comparePoints(delta.start, delta.end))
|
||||
return;
|
||||
|
||||
if (isInsert && delta.lines.length > 0xFFFF)
|
||||
if (isInsert && delta.lines.length > 0xF000)
|
||||
this.$splitAndapplyLargeDelta(delta);
|
||||
|
||||
// Apply.
|
||||
|
|
@ -579,22 +583,23 @@ var Document = function(textOrLines) {
|
|||
this.$splitAndapplyLargeDelta = function(delta) {
|
||||
// Split large insert deltas. This is necessary because:
|
||||
// 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 mallest threshold is on safari 0xFFFF.
|
||||
// 2. fn.apply() doesn't work for a large number of params. The smallest threshold is on safari 0xFFFF.
|
||||
// we use 0xF000 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
|
||||
// delta handling is too slow. If we make delete delta handling faster we can split all large deltas
|
||||
// as shown in https://gist.github.com/aldendaniels/8367109#file-document-snippet-js
|
||||
// If we do this, update validateDelta() to limit the number of lines in a delete delta.
|
||||
while (delta.lines.length > 0xFFFF) {
|
||||
while (delta.lines.length > 0xF000) {
|
||||
// Get split deltas.
|
||||
var lines = delta.lines.splice(0, 0xFFFF);
|
||||
var lines = delta.lines.splice(0, 0xF000);
|
||||
lines.push("");
|
||||
var start = delta.start;
|
||||
this.applyDelta({
|
||||
action: delta.action,
|
||||
lines: lines,
|
||||
start: this.pos(start.row, start.column),
|
||||
end: this.pos(start.row += 0xFFFF, start.column = 0) // Updates remaining delta.
|
||||
start: this.pos(start.row, start.column),
|
||||
end: this.pos(start.row += 0xF000, start.column = 0) // Updates remaining delta.
|
||||
}, true);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
|
|||
**/
|
||||
this.onUpdate = function(event) {
|
||||
var delta = event.data;
|
||||
var range = delta.range;
|
||||
var range = delta;
|
||||
if(range.start.row !== range.end.row) return;
|
||||
if(range.start.row !== this.pos.row) return;
|
||||
if (this.$updating) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue