Exemplo n.º 1
0
        public override string GetIndentationString(int lineNumber)
        {
            if (lineNumber < 1 || lineNumber > editor.LineCount)
            {
                return("");
            }
            var doc = context.AnalysisDocument;

            if (doc == null)
            {
                return(editor.GetLineIndent(lineNumber));
            }
            var snapshot    = editor.TextView.TextBuffer.CurrentSnapshot;
            var caretLine   = snapshot.GetLineFromLineNumber(lineNumber - 1);
            int?indentation = smartIndentationService.GetDesiredIndentation(editor.TextView, caretLine);

            if (indentation.HasValue && indentation.Value > 0)
            {
                return(CalculateIndentationString(indentation.Value));
            }

            var line = editor.GetLine(lineNumber);

            if (line == null)
            {
                return(editor.GetLineIndent(lineNumber));
            }
            try {
                if (line.Contains(editor.CaretOffset))
                {
                    var syntaxRoot = doc.GetSyntaxRootSynchronously(default);