Updated undo plugin to handle command states when entering/leaving enterMode.