added support for getNext/getPrev on insertions

This commit is contained in:
DadaMonad
2015-04-07 10:37:50 +00:00
parent 6d99ed07f0
commit d9c5ab5fa8
11 changed files with 203 additions and 37 deletions

View File

@@ -281,6 +281,28 @@ module.exports = function() {
}
};
Insert.prototype.getNext = function() {
var n;
n = this.next_cl;
while (n.is_deleted && (n.next_cl != null)) {
n = n.next_cl;
}
return n;
};
Insert.prototype.getPrev = function() {
var n;
n((function(_this) {
return function() {
return _this.prev_cl;
};
})(this));
while (n.is_deleted && (n.prev_cl != null)) {
n = n.prev_cl;
}
return n;
};
Insert.prototype.applyDelete = function(o) {
var callLater, garbagecollect, _ref;
if (this.deleted_by == null) {

View File

@@ -385,15 +385,15 @@ module.exports = function() {
Composition.prototype.callOperationSpecificInsertEvents = function(op) {
var o;
if (this.composition_ref.next_cl === op) {
o.undo_delta = this.custom_type._apply(op.content);
op.undo_delta = this.getCustomType()._apply(op.content);
} else {
o = this.end.prev_cl;
while (o !== op) {
this.custom_type._unapply(o.undo_delta);
this.getCustomType()._unapply(o.undo_delta);
o = o.next_cl;
}
while (o !== this.end) {
o.undo_delta = this.custom_type._apply(o.content);
o.undo_delta = this.getCustomType()._apply(o.content);
o = o.next_cl;
}
}
@@ -410,7 +410,7 @@ module.exports = function() {
Composition.prototype.callOperationSpecificDeleteEvents = function(op, del_op) {};
Composition.prototype.applyDelta = function(delta) {
(new ops.Insert(null, content, this, null, this.end.prev_cl, this.end)).execute();
(new ops.Insert(null, delta, this, null, this.end.prev_cl, this.end)).execute();
return void 0;
};