Skip to content

Commit 701d5f3

Browse files
ederzzederjiang
andauthored
fix: add try/finally block in withoutSaving method to ensure state restoration (#5837)
Co-authored-by: ederjiang <[email protected]>
1 parent 4aa16bb commit 701d5f3

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.changeset/rotten-poems-collect.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'slate-history': patch
3+
---
4+
5+
fix: add try/finally block in withoutSaving method to ensure state restoration

packages/slate-history/src/history-editor.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ export const HistoryEditor = {
120120
withoutSaving(editor: HistoryEditor, fn: () => void): void {
121121
const prev = HistoryEditor.isSaving(editor)
122122
SAVING.set(editor, false)
123-
fn()
124-
SAVING.set(editor, prev)
123+
try {
124+
fn()
125+
} finally {
126+
SAVING.set(editor, prev)
127+
}
125128
},
126129
}

0 commit comments

Comments
 (0)