internal SnapshotSpan GetCurrentSpanInSnapshot(ViewTextSpan originalSpan, ITextSnapshot textSnapshot) { var start = _disconnectedBufferGraph.ViewSnapshot.CreateTrackingPoint(originalSpan.TextSpan.Start, PointTrackingMode.Negative).GetPosition(textSnapshot); var end = Math.Max(start, this.CommitTrackingSpanEndPoint.GetPosition(textSnapshot)); return(new SnapshotSpan( textSnapshot, Span.FromBounds(start, end))); }
internal string GetCurrentTextInSnapshot( ViewTextSpan originalSpan, ITextSnapshot textSnapshot, int?endPoint = null) { var currentSpan = GetCurrentSpanInSnapshot(originalSpan, textSnapshot); var startPosition = currentSpan.Start; var endPosition = endPoint.HasValue ? endPoint.Value : currentSpan.End; // TODO(cyrusn): What to do if the span is empty, or the end comes before the start. // Can that even happen? Not sure, so we'll just be resilient just in case. return(startPosition <= endPosition ? textSnapshot.GetText(Span.FromBounds(startPosition, endPosition)) : string.Empty); }
internal string GetCurrentTextInSnapshot( ViewTextSpan originalSpan, ITextSnapshot textSnapshot, int? endPoint = null) { var currentSpan = GetCurrentSpanInSnapshot(originalSpan, textSnapshot); var startPosition = currentSpan.Start; var endPosition = endPoint.HasValue ? endPoint.Value : currentSpan.End; // TODO(cyrusn): What to do if the span is empty, or the end comes before the start. // Can that even happen? Not sure, so we'll just be resilient just in case. return startPosition <= endPosition ? textSnapshot.GetText(Span.FromBounds(startPosition, endPosition)) : string.Empty; }
internal SnapshotSpan GetCurrentSpanInSnapshot(ViewTextSpan originalSpan, ITextSnapshot textSnapshot) { var start = _disconnectedBufferGraph.ViewSnapshot.CreateTrackingPoint(originalSpan.TextSpan.Start, PointTrackingMode.Negative).GetPosition(textSnapshot); var end = Math.Max(start, this.CommitTrackingSpanEndPoint.GetPosition(textSnapshot)); return new SnapshotSpan( textSnapshot, Span.FromBounds(start, end)); }