preliminary undo-redo fixes
This commit is contained in:
@@ -4,11 +4,12 @@ class ReverseOperation {
|
||||
constructor (y, transaction) {
|
||||
this.created = new Date()
|
||||
const beforeState = transaction.beforeState
|
||||
this.toState = new ID(y.userID, y.ss.getState(y.userID) - 1)
|
||||
if (beforeState.has(y.userID)) {
|
||||
this.toState = new ID(y.userID, y.ss.getState(y.userID) - 1)
|
||||
this.fromState = new ID(y.userID, beforeState.get(y.userID))
|
||||
} else {
|
||||
this.fromState = this.toState
|
||||
this.toState = null
|
||||
this.fromState = null
|
||||
}
|
||||
this.deletedStructs = transaction.deletedStructs
|
||||
}
|
||||
@@ -30,28 +31,28 @@ function applyReverseOperation (y, scope, reverseBuffer) {
|
||||
while (!performedUndo && reverseBuffer.length > 0) {
|
||||
let undoOp = reverseBuffer.pop()
|
||||
// make sure that it is possible to iterate {from}-{to}
|
||||
y.os.getItemCleanStart(undoOp.fromState)
|
||||
y.os.getItemCleanEnd(undoOp.toState)
|
||||
y.os.iterate(undoOp.fromState, undoOp.toState, op => {
|
||||
if (!op._deleted && isStructInScope(y, op, scope)) {
|
||||
performedUndo = true
|
||||
op._delete(y)
|
||||
}
|
||||
})
|
||||
if (undoOp.fromState !== null) {
|
||||
let start = y.os.getItemCleanStart(undoOp.fromState)
|
||||
y.os.getItemCleanEnd(undoOp.toState)
|
||||
console.log(start)
|
||||
y.os.iterate(undoOp.fromState, undoOp.toState, op => {
|
||||
debugger
|
||||
if (op._deleted && op._redone !== null) {
|
||||
op = op._redone
|
||||
}
|
||||
if (op._deleted === false && isStructInScope(y, op, scope)) {
|
||||
performedUndo = true
|
||||
op._delete(y)
|
||||
}
|
||||
})
|
||||
}
|
||||
for (let op of undoOp.deletedStructs) {
|
||||
if (
|
||||
isStructInScope(y, op, scope) &&
|
||||
op._parent !== y &&
|
||||
!op._parent._deleted &&
|
||||
(
|
||||
op._parent._id.user !== y.userID ||
|
||||
op._parent._id.clock < undoOp.fromState.clock ||
|
||||
op._parent._id.clock > undoOp.fromState.clock
|
||||
)
|
||||
op._parent !== y
|
||||
) {
|
||||
performedUndo = true
|
||||
op = op._copy(undoOp.deletedStructs, true)
|
||||
op._integrate(y)
|
||||
op._redo(y)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user