public static List <LineRange> Insert(this List <LineRange> list, LineRange item) { int index = list.BinarySearch(item, (a, b) => a.FirstLine.CompareTo(item.FirstLine)); index = Math.Abs(index); return(list); }
public static IEnumerable <LineRange> GroupLineRanges(IEnumerable <ContentChangeLine> changes) { LineRange prev = null; foreach (var c in changes) { var current = c.AsLineRange(); if (prev == null) { prev = current; continue; } } yield break; }
public static LineRange AsLineRange(this ContentChangeLine line) { LineRange result = null; if (line.OldLineNo < 0 && line.NewLineNo > 0) { result = new LineRange(line.NewLineNo, line.NewLineNo + line.NumLines); result.status = DiffStatus.New; } else if (line.OldLineNo < 0 && line.NewLineNo > 0) { result = new LineRange(line.OldLineNo, line.OldLineNo + line.NumLines); result.status = DiffStatus.Removed; } return(result); }