diff --git a/app/src/protyle/undo/index.ts b/app/src/protyle/undo/index.ts index 46591d70a..3a7f10e36 100644 --- a/app/src/protyle/undo/index.ts +++ b/app/src/protyle/undo/index.ts @@ -64,7 +64,9 @@ class Undo { } public replace(doOperations: IOperation[]) { - this.undoStack[this.undoStack.length - 1].doOperations = doOperations; + if (this.undoStack.length > 0) { + this.undoStack[this.undoStack.length - 1].doOperations = doOperations; + } } public add( doOperations: IOperation[], undoOperations: IOperation[]) {