Alsing.Windows.Forms.SyntaxBox.EditViewControl.OutdentEndRow C# (CSharp) Method

OutdentEndRow() private method

private OutdentEndRow ( ) : void
return void
        private void OutdentEndRow()
        {
            try
            {
                if (Indent == IndentStyle.Scope)
                {
                    Row xtr = Caret.CurrentRow;
                    var indent1 = new String('\t', Caret.CurrentRow.Depth);
                    var tr = new TextRange
                             {
                                 FirstColumn = 0,
                                 LastColumn = xtr.GetLeadingWhitespace().Length,
                                 FirstRow = xtr.Index,
                                 LastRow = xtr.Index
                             };

                    Document.DeleteRange(tr);
                    Document.InsertText(indent1, 0, xtr.Index, true);

                    int diff = indent1.Length - tr.LastColumn;
                    Caret.Position.X += diff;
                    Caret.SetPos(Caret.Position);
                    Caret.CropPosition();
                    Selection.ClearSelection();
                    Caret.CurrentRow.Parse(false);
                    Caret.CurrentRow.Parse(true);
                }
                else if (Indent == IndentStyle.Smart)
                {
                    Row xtr = Caret.CurrentRow;

                    if (xtr.FirstNonWsWord == xtr.expansion_EndSpan.EndWord)
                    {
                        //int j=xtr.Expansion_StartRow.StartWordIndex;
                        string indent1 =
                            xtr.startSpan.StartWord.Row.GetVirtualLeadingWhitespace();
                        var tr = new TextRange
                                 {
                                     FirstColumn = 0,
                                     LastColumn = xtr.GetLeadingWhitespace().Length,
                                     FirstRow = xtr.Index,
                                     LastRow = xtr.Index
                                 };
                        Document.DeleteRange(tr);
                        string ts = "\t" + new String(' ', TabSize);
                        while (indent1.IndexOf(ts) >= 0)
                        {
                            indent1 = indent1.Replace(ts, "\t\t");
                        }
                        Document.InsertText(indent1, 0, xtr.Index, true);

                        int diff = indent1.Length - tr.LastColumn;
                        Caret.Position.X += diff;
                        Caret.SetPos(Caret.Position);
                        Caret.CropPosition();
                        Selection.ClearSelection();
                        Caret.CurrentRow.Parse(false);
                        Caret.CurrentRow.Parse(true);
                    }
                }
            }
            catch {}
        }