Adapter IDocumentAccessor -> TextDocument
Inheritance: IDocumentAccessor
		/// <inheritdoc cref="IIndentationStrategy.IndentLine" />
		public override int IndentLine(TextDocument document, DocumentLine line, int caretOffset)
		{
			var lineNr = line.LineNumber;
			var acc = new TextDocumentAccessor(document, lineNr, lineNr);
			var result = Indent(acc, false, caretOffset);

			var t = acc.Text;
			if (t.Length == 0)
			{
				// use AutoIndentation for new lines in comments / verbatim strings.
				return base.IndentLine(document, line, caretOffset);
			}

			return result;
		}
Exemplo n.º 2
0
        /// <inheritdoc cref="IIndentationStrategy.IndentLine" />
        public override int IndentLine(TextDocument document, DocumentLine line, int caretOffset)
        {
            var lineNr = line.LineNumber;
            var acc    = new TextDocumentAccessor(document, lineNr, lineNr);
            var result = Indent(acc, false, caretOffset);

            var t = acc.Text;

            if (t.Length == 0)
            {
                // use AutoIndentation for new lines in comments / verbatim strings.
                return(base.IndentLine(document, line, caretOffset));
            }

            return(result);
        }
        /// <inheritdoc cref="IIndentationStrategy.IndentLine" />
        public override int IndentLine(TextDocument document, DocumentLine line, int caretIndex)
        {
            if (line == null)
            {
                return caretIndex;
            }

            var lineNr = line.LineNumber;
            var acc = new TextDocumentAccessor(document, lineNr, lineNr);

            var leadingWhiteSpaceBefore = TextUtilities.GetLeadingWhitespace(document, line).Length;
            var result = Indent(acc, false, caretIndex);
            var t = acc.Text;

            result = caretIndex + TextUtilities.GetLeadingWhitespace(document, line).Length - leadingWhiteSpaceBefore;

            if (t.Length == 0)
            {
                // use AutoIndentation for new lines in comments / verbatim strings.
                return base.IndentLine(document, line, caretIndex);
            }

            return result;
        }