Generalize for document
This commit is contained in:
parent
93a560885b
commit
84e3687e01
2 changed files with 11 additions and 13 deletions
|
|
@ -42,7 +42,7 @@ var oop = require("./lib/oop");
|
|||
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
||||
var Range = require("./range").Range;
|
||||
var Anchor = require("./anchor").Anchor;
|
||||
|
||||
var lang = require("./lib/lang");
|
||||
/**
|
||||
* class Document
|
||||
*
|
||||
|
|
@ -327,14 +327,7 @@ var Document = function(text) {
|
|||
return {row: row, column: 0};
|
||||
|
||||
var args = [row, 0];
|
||||
var step = 100000;
|
||||
var l = Math.ceil(lines.length / step);
|
||||
for (var tlines, i = 0; i < l; i++) {
|
||||
tlines = lines.slice(i * step, step);
|
||||
args.push.apply(args, tlines);
|
||||
this.$lines.splice.apply(this.$lines, args);
|
||||
}
|
||||
|
||||
this.$lines = lang.chunkLines(lines, this.$lines, args, true);
|
||||
var range = new Range(row, 0, row + lines.length, 0);
|
||||
var delta = {
|
||||
action: "insertLines",
|
||||
|
|
|
|||
|
|
@ -147,16 +147,21 @@ exports.deferredCall = function(fcn) {
|
|||
return deferred;
|
||||
};
|
||||
|
||||
|
||||
exports.chunkLines = function(args, thingToSplice, thingtoApply) {
|
||||
// because of Document, this is confusing as shit
|
||||
exports.chunkLines = function(args, thingToSplice, thingtoApply, isDocument) {
|
||||
if (thingtoApply === undefined)
|
||||
thingtoApply = thingToSplice;
|
||||
|
||||
|
||||
var step = 100000;
|
||||
var l = Math.ceil(args.length / step);
|
||||
for (var targs, i = 0; i < l; i++) {
|
||||
targs = args.slice(i * step, step);
|
||||
thingToSplice.slice.apply(thingtoApply, targs);
|
||||
if (isDocument) {
|
||||
thingtoApply.push.apply(thingtoApply, targs);
|
||||
thingToSplice.splice.apply(thingToSplice, thingtoApply);
|
||||
}
|
||||
else
|
||||
thingToSplice.slice.apply(thingtoApply, targs);
|
||||
}
|
||||
|
||||
return thingToSplice;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue