Search code examples
javascriptundoundo-redo

Clear UNDO history of events in browser with JavaScript?


I have a CodeMirror instance written in Javascript that acts as a code editor. I load the code for the procedure the user selects..when the user selects one procedure then another I just call the set the value to the code of that procedure. When I do this and the user clicks CTRL+Z or right click, undo it brings back the previous procedure. I need to clear the undo history when I call set value..can't find out how to do this have looked all over..any help?


Solution

  • What about clearHistory() . it works for me. call it when user selects a procedure.

    editor.clearHistory()
    

    or you can completely disable the undo feature by using "undoDepth" in codemirror configuration

    undoDepth : 0 ,