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

GetWhitespaceBefore() private method

private GetWhitespaceBefore ( ITextSource textSource, int offset ) : ISegment
textSource ITextSource
offset int
return ISegment
		public static ISegment GetWhitespaceBefore(ITextSource textSource, int offset)
		{
			if (textSource == null)
				throw new ArgumentNullException("textSource");
			int pos;
			for (pos = offset - 1; pos >= 0; pos--)
			{
				var c = textSource.GetCharAt(pos);
				if (c != ' ' && c != '\t')
					break;
			}
			pos++; // go back the one character that isn't whitespace
			return new SimpleSegment(pos, offset - pos);
		}