public void Undo()
{
if (history.Count > 0)
{
var cmd = history.Pop();
//
BeginDisableCommands();//prevent text changing into handlers
try
{
cmd.Undo();
}
finally
{
EndDisableCommands();
}
//
redoStack.Push(cmd);
}
//undo next autoUndo command
if (history.Count > 0)
{
if (history.Peek().autoUndo)
Undo();
}
TextSource.CurrentTB.OnUndoRedoStateChanged();
}