AvalonStudio.TextEditor.Document.TextUtilities.GetSingleIndentationSegment C# (CSharp) Method

GetSingleIndentationSegment() public static method

Gets a single indentation segment starting at offset - at most one tab or indentationSize spaces.
public static GetSingleIndentationSegment ( ITextSource textSource, int offset, int indentationSize ) : ISegment
textSource ITextSource The text source.
offset int The offset where the indentation segment starts.
indentationSize int The size of an indentation unit. See .
return ISegment
		public static ISegment GetSingleIndentationSegment(ITextSource textSource, int offset, int indentationSize)
		{
			if (textSource == null)
				throw new ArgumentNullException("textSource");
			var pos = offset;
			while (pos < textSource.TextLength)
			{
				var c = textSource.GetCharAt(pos);
				if (c == '\t')
				{
					if (pos == offset)
						return new SimpleSegment(offset, 1);
					break;
				}
				if (c == ' ')
				{
					if (pos - offset >= indentationSize)
						break;
				}
				else
				{
					break;
				}
				// continue only if c==' ' and (pos-offset)<tabSize
				pos++;
			}
			return new SimpleSegment(offset, pos - offset);
		}