/// <summary> /// Returns intersection with other range, /// empty range returned otherwise /// </summary> /// <param name="range"></param> /// <returns></returns> public virtual Range GetIntersectionWith(Range range) { if (ColumnSelectionMode) { return(GetIntersectionWith_ColumnSelectionMode(range)); } Range r1 = this.Clone(); Range r2 = range.Clone(); r1.Normalize(); r2.Normalize(); Place newStart = r1.Start > r2.Start ? r1.Start : r2.Start; Place newEnd = r1.End < r2.End ? r1.End : r2.End; if (newEnd < newStart) { return(new Range(tb, start, start)); } return(tb.GetRange(newStart, newEnd)); }