SafeUpdateIndentEngine() private method

private SafeUpdateIndentEngine ( int offset ) : void
offset int
return void
        public override async Task PostFomatPastedText(int insertionOffset, int insertedChars)
        {
            if (indent.Editor.Options.IndentStyle == IndentStyle.None ||
                indent.Editor.Options.IndentStyle == IndentStyle.Auto)
            {
                return;
            }
            if (DefaultSourceEditorOptions.Instance.OnTheFlyFormatting)
            {
                var tree = await indent.DocumentContext.AnalysisDocument.GetSyntaxTreeAsync();

                var startLine        = indent.Editor.GetLineByOffset(insertionOffset);
                var endLine          = indent.Editor.GetLineByOffset(insertionOffset + insertedChars);
                int lineStartOffset  = startLine.Offset != endLine.Offset ? startLine.Offset : insertionOffset;
                int formatCharsCount = insertedChars + (insertionOffset - lineStartOffset);
                var policy           = indent.DocumentContext.GetFormattingPolicy();
                var textPolicy       = indent.DocumentContext.Project.Policies.Get <Ide.Gui.Content.TextStylePolicy> (indent.Editor.MimeType);
                var optionSet        = policy.CreateOptions(textPolicy);
                var span             = new TextSpan(lineStartOffset, formatCharsCount);
                var doc = await Formatter.FormatAsync(indent.DocumentContext.AnalysisDocument, span, optionSet);

                OnTheFlyFormatter.ApplyNewTree(indent.Editor, lineStartOffset, true, span, tree, await doc.GetSyntaxTreeAsync());
                return;
            }
            // Just correct the start line of the paste operation - the text is already indented.
            var curLine       = indent.Editor.GetLineByOffset(insertionOffset);
            var curLineOffset = curLine.Offset;

            indent.SafeUpdateIndentEngine(curLineOffset);
            if (!indent.stateTracker.IsInsideOrdinaryCommentOrString)
            {
                int    pos       = curLineOffset;
                string curIndent = curLine.GetIndentation(indent.Editor);
                int    nlwsp     = curIndent.Length;
                if (!indent.stateTracker.LineBeganInsideMultiLineComment || (nlwsp < curLine.LengthIncludingDelimiter && indent.Editor.GetCharAt(curLineOffset + nlwsp) == '*'))
                {
                    // Possibly replace the indent
                    indent.SafeUpdateIndentEngine(curLineOffset + curLine.Length);
                    string newIndent = indent.stateTracker.ThisLineIndent;
                    if (newIndent != curIndent)
                    {
                        if (CompletionWindowManager.IsVisible)
                        {
                            if (pos < CompletionWindowManager.CodeCompletionContext.TriggerOffset)
                            {
                                CompletionWindowManager.CodeCompletionContext.TriggerOffset -= nlwsp;
                            }
                        }
                        indent.Editor.ReplaceText(pos, nlwsp, newIndent);
                        //						textEditorData.Document.CommitLineUpdate (textEditorData.CaretLine);
                    }
                }
            }
            indent.Editor.FixVirtualIndentation();
        }
        public override void PostFomatPastedText(int insertionOffset, int insertedChars)
        {
            if (indent.Editor.Options.IndentStyle == IndentStyle.None ||
                indent.Editor.Options.IndentStyle == IndentStyle.Auto)
            {
                return;
            }
            if (DefaultSourceEditorOptions.Instance.OnTheFlyFormatting)
            {
                int lineStartOffset  = indent.Editor.GetLineByOffset(insertionOffset).Offset;
                int formatCharsCount = insertedChars + (lineStartOffset - insertionOffset);
                var newText          = CSharpFormatter.FormatText(
                    indent.DocumentContext.GetFormattingPolicy(),
                    indent.DocumentContext.Project.Policies.Get <Ide.Gui.Content.TextStylePolicy> (),
                    indent.Editor.GetTextBetween(lineStartOffset, insertionOffset + insertedChars),
                    0,
                    formatCharsCount
                    );
                indent.Editor.ReplaceText(lineStartOffset, formatCharsCount, newText);
                return;
            }
            // Just correct the start line of the paste operation - the text is already indented.
            var curLine       = indent.Editor.GetLineByOffset(insertionOffset);
            var curLineOffset = curLine.Offset;

            indent.SafeUpdateIndentEngine(curLineOffset);
            if (!indent.stateTracker.IsInsideOrdinaryCommentOrString)
            {
                int    pos       = curLineOffset;
                string curIndent = curLine.GetIndentation(indent.Editor);
                int    nlwsp     = curIndent.Length;

                if (!indent.stateTracker.LineBeganInsideMultiLineComment || (nlwsp < curLine.LengthIncludingDelimiter && indent.Editor.GetCharAt(curLineOffset + nlwsp) == '*'))
                {
                    // Possibly replace the indent
                    indent.SafeUpdateIndentEngine(curLineOffset + curLine.Length);
                    string newIndent = indent.stateTracker.ThisLineIndent;
                    if (newIndent != curIndent)
                    {
                        if (CompletionWindowManager.IsVisible)
                        {
                            if (pos < CompletionWindowManager.CodeCompletionContext.TriggerOffset)
                            {
                                CompletionWindowManager.CodeCompletionContext.TriggerOffset -= nlwsp;
                            }
                        }
                        indent.Editor.ReplaceText(pos, nlwsp, newIndent);
                        //						textEditorData.Document.CommitLineUpdate (textEditorData.CaretLine);
                    }
                }
            }
            indent.Editor.FixVirtualIndentation();
        }
        public override void PostFomatPastedText(int insertionOffset, int insertedChars)
        {
            if (indent.Editor.Options.IndentStyle == IndentStyle.None ||
                indent.Editor.Options.IndentStyle == IndentStyle.Auto)
            {
                return;
            }

            // Just correct the start line of the paste operation - the text is already indented.
            var curLine       = indent.Editor.GetLineByOffset(insertionOffset);
            var curLineOffset = curLine.Offset;

            indent.SafeUpdateIndentEngine(curLineOffset);
            if (!indent.stateTracker.IsInsideOrdinaryCommentOrString)
            {
                int    pos       = curLineOffset;
                string curIndent = curLine.GetIndentation(indent.Editor);
                int    nlwsp     = curIndent.Length;

                if (!indent.stateTracker.LineBeganInsideMultiLineComment || (nlwsp < curLine.LengthIncludingDelimiter && indent.Editor.GetCharAt(curLineOffset + nlwsp) == '*'))
                {
                    // Possibly replace the indent
                    indent.SafeUpdateIndentEngine(curLineOffset + curLine.Length);
                    string newIndent = indent.stateTracker.ThisLineIndent;
                    if (newIndent != curIndent)
                    {
                        if (CompletionWindowManager.IsVisible)
                        {
                            if (pos < CompletionWindowManager.CodeCompletionContext.TriggerOffset)
                            {
                                CompletionWindowManager.CodeCompletionContext.TriggerOffset -= nlwsp;
                            }
                        }
                        indent.Editor.ReplaceText(pos, nlwsp, newIndent);
                        //						textEditorData.Document.CommitLineUpdate (textEditorData.CaretLine);
                    }
                }
            }
            indent.Editor.FixVirtualIndentation();
        }