From a84cd4a6dd0b4afd7b082ae40377427b4eb6449b Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 14 Sep 2023 20:08:41 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/9178 --- app/src/protyle/undo/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/protyle/undo/index.ts b/app/src/protyle/undo/index.ts index 8cda95be2..7208a3b95 100644 --- a/app/src/protyle/undo/index.ts +++ b/app/src/protyle/undo/index.ts @@ -68,6 +68,12 @@ export class Undo { } 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) { this.undoStack[this.undoStack.length - 1].doOperations = doOperations; }