diff --git a/src/history.ts b/src/history.ts index 20bdddef1..9a94accc3 100644 --- a/src/history.ts +++ b/src/history.ts @@ -34,6 +34,10 @@ class SceneHistory { this.skipRecording(); } + clearRedoStack() { + this.redoStack.splice(0, this.redoStack.length); + } + redoOnce(elements: ExcalidrawElement[]) { const currentEntry = this.generateCurrentEntry(elements); const entryToRestore = this.redoStack.pop(); diff --git a/src/index.tsx b/src/index.tsx index e210b3212..32f4e314a 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -203,7 +203,6 @@ class App extends React.Component<{}, AppState> { } else if (shapesShortcutKeys.includes(event.key.toLowerCase())) { this.setState({ elementType: findShapeByKey(event.key) }); } else if (event.metaKey && event.code === "KeyZ") { - const currentEntry = history.generateCurrentEntry(elements); if (event.shiftKey) { // Redo action history.redoOnce(elements); @@ -914,7 +913,7 @@ class App extends React.Component<{}, AppState> { saveToLocalStorage(elements, this.state); if (history.isRecording()) { history.pushEntry(history.generateCurrentEntry(elements)); - history.redoStack.splice(0, history.redoStack.length); + history.clearRedoStack(); } history.resumeRecording(); }