private void MapUpToBufferNoTrack(Predicate <ITextBuffer> match, FrugalList <SnapshotSpan> mappedSpans) { ITextSnapshot targetSnapshot = MappingHelper.FindCorrespondingSnapshot(_root, match); if (targetSnapshot != null) { //Map _anchor up to targetSnapshot (they should be concurrent snapshots) MapUpToSnapshotNoTrack(targetSnapshot, mappedSpans); } }
private SnapshotPoint?MapUpToFirstMatchNoTrack(Predicate <ITextBuffer> match, PositionAffinity affinity) { ITextSnapshot targetSnapshot = MappingHelper.FindCorrespondingSnapshot(_root, match); if (targetSnapshot != null) { //Map _anchor up to targetSnapshot (they should be concurrent snapshots) return(MapUpToSnapshotNoTrack(targetSnapshot, affinity)); } return(null); }
private SnapshotPoint?MapUpToBufferNoTrack(ITextBuffer targetBuffer, PositionAffinity affinity) { ITextSnapshot targetSnapshot = MappingHelper.FindCorrespondingSnapshot(_root, targetBuffer); if (targetSnapshot != null) { //Map _anchor up to targetSnapshot (they should be concurrent snapshots) return(MapUpToSnapshotNoTrack(targetSnapshot, affinity)); } return(null); }
private MappingSpanSnapshot(ITextSnapshot root, SnapshotSpan anchor, SpanTrackingMode trackingMode, IBufferGraph graph) { //Anchor and root are expected to be from concurrent snapshots ITextSnapshot correspondingAnchorSnapshot = MappingHelper.FindCorrespondingSnapshot(root, anchor.Snapshot.TextBuffer); _root = root; if (correspondingAnchorSnapshot != null) { _anchor = anchor.TranslateTo(correspondingAnchorSnapshot, trackingMode); } else { _anchor = anchor; _unmappable = true; } _trackingMode = trackingMode; _graph = graph; }
public NormalizedSnapshotSpanCollection GetSpans(ITextBuffer targetBuffer) { if (targetBuffer == null) { throw new ArgumentNullException("targetBuffer"); } if (_unmappable) { return(NormalizedSnapshotSpanCollection.Empty); } if (targetBuffer.Properties.ContainsProperty("IdentityMapping")) { // text buffer properties uses the hybrid dictionary, which requires TWO lookups to determine that // a key is not present. Since this test usually fails, do it the hard way (the second lookup shows up // in scrolling profiles). ITextBuffer doppelganger = (ITextBuffer)targetBuffer.Properties["IdentityMapping"]; if (doppelganger == _anchor.Snapshot.TextBuffer) { // We are mapping up from a doppelganger buffer; the coordinates will be the same. We // just need to figure out the right snapshot. ITextSnapshot targetSnapshot = MappingHelper.FindCorrespondingSnapshot(_root, targetBuffer); return(new NormalizedSnapshotSpanCollection(new SnapshotSpan(targetSnapshot, _anchor.Span))); } } //Try mapping down first. FrugalList <SnapshotSpan> mappedSpans = new FrugalList <SnapshotSpan>(); MappingHelper.MapDownToBufferNoTrack(_anchor, targetBuffer, mappedSpans); if (mappedSpans.Count == 0) { //Unable to map down ... try mapping up. this.MapUpToBufferNoTrack(targetBuffer, mappedSpans); } return(new NormalizedSnapshotSpanCollection(mappedSpans)); }