Ejemplo n.º 1
0
            internal TrackingCacheData Merge(ITextSnapshot snapshot, TrackingCacheData trackingCacheData)
            {
                var          left  = TrackingSpan.GetSpanSafe(snapshot);
                var          right = trackingCacheData.TrackingSpan.GetSpanSafe(snapshot);
                SnapshotSpan span;

                if (left.HasValue && right.HasValue)
                {
                    span = left.Value.CreateOverarching(right.Value);
                }
                else if (left.HasValue)
                {
                    span = left.Value;
                }
                else if (right.HasValue)
                {
                    span = right.Value;
                }
                else
                {
                    span = new SnapshotSpan(snapshot, 0, 0);
                }
                var trackingSpan = snapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgeInclusive);

                var tagList = TrackingList
                              .Concat(trackingCacheData.TrackingList)
                              .Distinct(EqualityUtility.Create <Tuple <ITrackingSpan, TTag> >(
                                            (x, y) => x.Item1.GetSpanSafe(snapshot) == y.Item1.GetSpanSafe(snapshot),
                                            tuple => tuple.Item1.GetSpanSafe(snapshot).GetHashCode()))
                              .ToReadOnlyCollection();

                return(new TrackingCacheData(trackingSpan, tagList));
            }