clearHistory() doesn't work

Hello, I’m creating a code editor, so i have a list of scripts I can edit. When I click on a script, his content goes on the editor (codemirror).
If I press ctrl+z the undo works well, but if I change script (so the content of the editor changes), the undo history the same as the other script, so if I undo i see the other changes I made with the other script.
I used editor.getDoc().clearHistory() to clear the undo history when I change script but it doesn’t work.
Any ideas?

1 Like

clearHistory works for me when I try it. Make sure you call it after setting the new document.

What do you mean by “setting the new document”?

Calling setValue.