fixed one more problem with ds & fixed ace example & insertions are combined even when created in different execution tasks
This commit is contained in:
parent
a7f845f553
commit
e1df1a7a12
@ -300,7 +300,12 @@ module.exports = function (Y /* :any */) {
|
||||
for (var sid in ls) {
|
||||
var l = ls[sid]
|
||||
var id = JSON.parse(sid)
|
||||
var op = yield* this.getInsertion(id)
|
||||
var op
|
||||
if (typeof id[1] === 'string') {
|
||||
op = yield* this.getOperation(id)
|
||||
} else {
|
||||
op = yield* this.getInsertion(id)
|
||||
}
|
||||
if (op == null) {
|
||||
store.listenersById[sid] = l
|
||||
} else {
|
||||
@ -338,6 +343,28 @@ module.exports = function (Y /* :any */) {
|
||||
yield* Y.Struct[op.struct].execute.call(this, op)
|
||||
yield* this.addOperation(op)
|
||||
yield* this.store.operationAdded(this, op)
|
||||
|
||||
// if insertion, try to combine with left
|
||||
if (op.left != null &&
|
||||
op.content != null &&
|
||||
op.left[0] === op.id[0] &&
|
||||
Y.utils.compareIds(op.left, op.origin)
|
||||
) {
|
||||
var left = yield* this.getInsertion(op.left)
|
||||
if (left.content != null &&
|
||||
left.id[1] + left.content.length === op.id[1] &&
|
||||
left.originOf.length === 1 &&
|
||||
!left.gc && !left.deleted &&
|
||||
!op.gc && !op.deleted
|
||||
) {
|
||||
// combine!
|
||||
left.originOf = op.originOf
|
||||
left.content = left.content.concat(op.content)
|
||||
left.right = op.right
|
||||
yield* this.os.delete(op.id)
|
||||
yield* this.setOperation(left)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -378,12 +378,12 @@ module.exports = function (Y/* :any */) {
|
||||
break
|
||||
} else {
|
||||
// we can extend n with next
|
||||
if (diff >= next.len) {
|
||||
if (diff > next.len) {
|
||||
// n is even longer than next
|
||||
// get next.next, and try to extend it
|
||||
var _next = yield* this.ds.findNext(next.id)
|
||||
yield* this.ds.delete(next.id)
|
||||
if (_next == null || n.id[0] !== next.id[0]) {
|
||||
if (_next == null || n.id[0] !== _next.id[0]) {
|
||||
break
|
||||
} else {
|
||||
next = _next
|
||||
|
Loading…
x
Reference in New Issue
Block a user