UndoManager: keep item before item is deleted (fixes some edge cases of followRedo)
This commit is contained in:
parent
d064e6e96e
commit
463065ac21
@ -62,17 +62,18 @@ const popStackItem = (undoManager, stack, eventType) => {
|
|||||||
})
|
})
|
||||||
const structs = /** @type {Array<GC|Item>} */ (store.clients.get(doc.clientID))
|
const structs = /** @type {Array<GC|Item>} */ (store.clients.get(doc.clientID))
|
||||||
iterateStructs(transaction, structs, stackItem.start, stackItem.len, struct => {
|
iterateStructs(transaction, structs, stackItem.start, stackItem.len, struct => {
|
||||||
if (struct instanceof Item && struct.redone !== null) {
|
if (struct instanceof Item && !struct.deleted && scope.some(type => isParentOf(type, /** @type {Item} */ (struct)))) {
|
||||||
let { item, diff } = followRedone(store, struct.id)
|
if (struct.redone !== null) {
|
||||||
if (diff > 0) {
|
let { item, diff } = followRedone(store, struct.id)
|
||||||
item = getItemCleanStart(transaction, store, struct.id)
|
if (diff > 0) {
|
||||||
|
item = getItemCleanStart(transaction, store, createID(item.id.client, item.id.clock + diff))
|
||||||
|
}
|
||||||
|
if (item.length > stackItem.len) {
|
||||||
|
getItemCleanStart(transaction, store, createID(item.id.client, item.id.clock + stackItem.len))
|
||||||
|
}
|
||||||
|
struct = item
|
||||||
}
|
}
|
||||||
if (item.length > stackItem.len) {
|
keepItem(struct)
|
||||||
getItemCleanStart(transaction, store, createID(item.id.client, item.id.clock + stackItem.len))
|
|
||||||
}
|
|
||||||
struct = item
|
|
||||||
}
|
|
||||||
if (!struct.deleted && scope.some(type => isParentOf(type, /** @type {Item} */ (struct)))) {
|
|
||||||
struct.delete(transaction)
|
struct.delete(transaction)
|
||||||
performedChange = true
|
performedChange = true
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user