Using the ACE Editor, it appears as if using editor.getSession().getUndoManager()
with a session that has been set with editor.setSession()
returns an UndoManager
object that contains only empty functions for undo()
, redo()
, and reset()
. It does not return an UndoManager with methods like hasUndo()
, or hasRedo()
, or any of the other documented methods. In the source, it looks like my the session must not have an $undoManager
and is forced to use an empty (and incomplete) $defaultUndoManager
:
this.$defaultUndoManager = {
undo: function() {},
redo: function() {},
reset: function() {}
};
this.getUndoManager = function() {
return this.$undoManager || this.$defaultUndoManager;
};
Why would a session that was set with editor.setSession() have an $undoManager
that is undefined
like that?
Looks like one is supposed to set undo manager on the session like this (ace.js#L112)
And if undomamager is missing defaultUndomanager is returned so that editor methods do not have to check for null, when accessing undomanager.
I think the reason EditSession doesn't create undoManager by itself is to allow users to provide special implementations of undomanager (e.g. for collaboration)