Skip to content

Commit 7bb57a8

Browse files
committed
Don't delete the initial content when using "Ctrl+Z" to undo
Resolves #5263
1 parent 8c62e90 commit 7bb57a8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

resources/scripts/components/elements/CodemirrorEditor.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,12 @@ export default ({ style, initialContent, filename, mode, fetchContent, onContent
191191
}, [editor, mode]);
192192

193193
useEffect(() => {
194-
editor && editor.setValue(initialContent || '');
194+
if (editor) {
195+
editor.setValue(initialContent || '');
196+
// Reset the history so that "Ctrl+Z" doesn't delete the intial content
197+
// we just set above.
198+
editor.setHistory({ done: [], undone: [] });
199+
}
195200
}, [editor, initialContent]);
196201

197202
useEffect(() => {

0 commit comments

Comments
 (0)