Merge pull request #453 from Cargo/main

Allow updating captureTimeout on UndoManager instances
This commit is contained in:
Kevin Jahns 2022-10-03 11:58:03 +02:00 committed by GitHub
commit 8fb73edd97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -192,6 +192,7 @@ export class UndoManager extends Observable {
this.doc = doc this.doc = doc
this.lastChange = 0 this.lastChange = 0
this.ignoreRemoteMapChanges = ignoreRemoteMapChanges this.ignoreRemoteMapChanges = ignoreRemoteMapChanges
this.captureTimeout = captureTimeout
/** /**
* @param {Transaction} transaction * @param {Transaction} transaction
*/ */
@ -223,7 +224,7 @@ export class UndoManager extends Observable {
}) })
const now = time.getUnixTime() const now = time.getUnixTime()
let didAdd = false let didAdd = false
if (now - this.lastChange < captureTimeout && stack.length > 0 && !undoing && !redoing) { if (now - this.lastChange < this.captureTimeout && stack.length > 0 && !undoing && !redoing) {
// append change to last stack op // append change to last stack op
const lastOp = stack[stack.length - 1] const lastOp = stack[stack.length - 1]
lastOp.deletions = mergeDeleteSets([lastOp.deletions, transaction.deleteSet]) lastOp.deletions = mergeDeleteSets([lastOp.deletions, transaction.deleteSet])