Skip to content

Commit ab09334

Browse files
authored
Don't delete the initial content when using "Ctrl+Z" to undo (#5448)
Resolves #5263
1 parent f1ea7ec commit ab09334

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)