internal void CombineOverlappingSelections() { var overlappingSelections = new List <int>(); var selections = Selections .Where(s => s.IsSelection()) .Select((selection, index) => new { index, selection }) .OrderBy(s => s.selection.Caret.GetPoint(Snapshot)) .ToList(); for (var index = 0; index < selections.Count - 1; index++) { var selection = selections[index].selection; var nextSelection = selections[index + 1].selection; if (selection.End.GetPoint(Snapshot) > nextSelection.Start.GetPoint(Snapshot)) { nextSelection.Start = Snapshot.CreateTrackingPoint(selection.Start.GetPosition(Snapshot)); if (selection.IsReversed(Snapshot)) { nextSelection.Caret = selection.Caret; } overlappingSelections.Add(selections[index].index); } } foreach (var index in overlappingSelections.OrderByDescending(n => n)) { Selections.RemoveAt(index); } }
internal void RemoveItem(int index) { Selections.RemoveAt(index); SelectedItems.Rows.RemoveAt(index); }