Explorar o código

:bug: fix https://github.com/siyuan-note/siyuan/issues/9178

Vanessa hai 1 ano
pai
achega
a84cd4a6dd
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      app/src/protyle/undo/index.ts

+ 6 - 0
app/src/protyle/undo/index.ts

@@ -68,6 +68,12 @@ export class Undo {
     }
     }
 
 
     public replace(doOperations: IOperation[]) {
     public replace(doOperations: IOperation[]) {
+        // undo 引发 replace 导致 stack 错误 https://github.com/siyuan-note/siyuan/issues/9178
+        if (this.hasUndo && this.redoStack.length > 0) {
+            this.undoStack.push(this.redoStack.pop())
+            this.redoStack = [];
+            this.hasUndo = false;
+        }
         if (this.undoStack.length > 0) {
         if (this.undoStack.length > 0) {
             this.undoStack[this.undoStack.length - 1].doOperations = doOperations;
             this.undoStack[this.undoStack.length - 1].doOperations = doOperations;
         }
         }