# PlayGround undo (ctrl-z) after ClearCode

**URL:** <https://forum.babylonjs.com/t/playground-undo-ctrl-z-after-clearcode/17457>\
**Category:** Feature requests\
**Created:** [January 13, 2021, 4:36pm UTC](https://forum.babylonjs.com/t/playground-undo-ctrl-z-after-clearcode/17457 "2021-01-13T16:36:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DerKarlos](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/derkarlos/32/4346_2.png) [@DerKarlos](https://forum.babylonjs.com/u/DerKarlos)\
**Post date:** [January 13, 2021, 4:36pm UTC](https://forum.babylonjs.com/t/playground-undo-ctrl-z-after-clearcode/17457/1 "2021-01-13T16:36:57Z")

</div>

😥 Editing my PG I accidentally hit Clear Code instead of Options  
All my edited changes are gone. Undo (with Ctrl-z) is not possible.  
Could you please implement any fool-prove function to avoid this?  
May be a “really” dialog,  
or an eye-catching “Undo” button.  
or that Ctrl-z please.

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gijs/32/44_2.png) [@Gijs](https://forum.babylonjs.com/u/Gijs)\
**Post date:** [January 13, 2021, 5:11pm UTC](https://forum.babylonjs.com/t/playground-undo-ctrl-z-after-clearcode/17457/2 "2021-01-13T17:11:18Z")

</div>

Sorry for your loss @DerKarlos☹  
You can enable the “really” dialog by enabling safe mode at the options.

If someone wants to implement the ctrl-z, in `monacoManager.ts` you can do this to replace the code while keeping the history:

```
public setCode(code: string) {
    let fullRange = this._editor.getModel()!.getFullModelRange();
    this._editor.executeEdits('monacoManager', [{ range: fullRange, text: code }]);
}
```

---

<div class="post-metadata">

**Author:** ![DerKarlos](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/derkarlos/32/4346_2.png) [@DerKarlos](https://forum.babylonjs.com/u/DerKarlos)\
**Post date:** [January 14, 2021, 7:45am UTC](https://forum.babylonjs.com/t/playground-undo-ctrl-z-after-clearcode/17457/3 "2021-01-14T07:45:53Z")

</div>

Thank you @Gijs, it was not that bad.  
Save Mode: Who reads the Manual anyway? I expected something like Auto-Save and did not want to spoil you server with endless versions.  
The “Really?” is fine. May be it could be the default while ctrl-Z still may be usefull.
