For a short explanation i want to replicate the behavior of sublime text when it comes to the state of the document (has changes/has no changes) in order to know if i have to promt the user with a save/yes/no dialog.
Related solutions that i found on the internet:
The second solution (which seems to be up to date with documentation) does not work, and here is an example:
//can use 'change' also with no effect
editor.on("input", function() {
var is_dirty = editor.session.getUndoManager().hasUndo();
//...
});
`is_dirty` does not work properly after writing a couple of letters and then doing an undo (plain old Ctrl+z). Maybe i'm doing something wrong here, in that case i need a way to debug this.
Considering that i found no documentation on the order of events (input/change) and when UndoManager gets updated it would help to have a documented solution for this. Here is one way it could work:
Have two events passed to the UndoManager 'undo_stack_changed' and 'redo_stack_changed' (or it could be just one for both) emitted when any stacks change by any input/change, undo, redo or reset operations. The events have to be sent after all stack operations are done inside undo manager so that hasUndo() and hasRedo() return correct values
Thanks,
Razvan.