/// <summary>
        /// Undo operation
        /// </summary>
        public override void Undo()
        {
            var tb = ts.CurrentTB;

            ts.OnTextChanging();

            tb.Selection.BeginUpdate();
            //tb.BeginUpdate();
            for (int i = 0; i < iLines.Count; i++)
            {
                int iLine = iLines[i];

                if (iLine < ts.Count)
                {
                    tb.Selection.Start = new Place(0, iLine);
                }
                else
                {
                    tb.Selection.Start = new Place(ts[ts.Count - 1].Count, ts.Count - 1);
                }

                InsertCharCommand.InsertLine(ts);
                tb.Selection.Start = new Place(0, iLine);
                string text = prevText[prevText.Count - i - 1];
                InsertTextCommand.InsertText(text, ts);
                ts[iLine].IsChanged = true;
                if (iLine < ts.Count - 1)
                {
                    ts[iLine + 1].IsChanged = true;
                }
                else
                {
                    ts[iLine - 1].IsChanged = true;
                }

                if (text.Trim() != string.Empty)
                {
                    ts.OnTextChanged(iLine, iLine);
                }
            }

            //tb.EndUpdate();
            tb.Selection.EndUpdate();

            ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
        }
        internal static void InsertText(string insertedText, TextSource ts)
        {
            var tb = ts.CurrentTB;

            try {
                tb.Selection.BeginUpdate();
                char cc = '\x0';
                if (ts.Count == 0)
                {
                    InsertCharCommand.InsertLine(ts);
                }

                tb.ExpandBlock(tb.Selection.Start.iLine);
                foreach (char c in insertedText)
                {
                    InsertCharCommand.InsertChar(c, ref cc, ts);
                }

                ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
            } finally {
                tb.Selection.EndUpdate();
            }
        }