Microsoft.VisualStudio.Editor.Mocks.TextSnapshotMock.GetLineFromPosition C# (CSharp) Method

GetLineFromPosition() public method

public GetLineFromPosition ( int position ) : ITextSnapshotLine
position int
return ITextSnapshotLine
        public ITextSnapshotLine GetLineFromPosition(int position) {
            for (int i = 0; i < _lines.Length; i++) {
                int start = _lines[i].Start.Position;
                int length = _lines[i].Length;

                if (length == _lines[i].Length) {
                    if ((start <= position && position <= start + length) || start == position + 1)
                        return _lines[i];
                } else {
                    if (start <= position && position < start + length)
                        return _lines[i];
                }
            }

            if (position == 0)
                return _lines[0];

            if (position >= _lines[_lines.Length - 1].Length)
                return _lines[_lines.Length - 1];

            return null;
        }