/// <summary> /// Shows the inline comments for the specified tag in a peek view. /// </summary> /// <param name="tag"></param> protected void ShowPeekComments( InlineCommentNavigationParams parameter, ITextView textView, ShowInlineCommentTag tag, IEnumerable <ITextView> allTextViews) { var point = peekService.Show(textView, tag); if (parameter?.MoveCursor != false) { var caretPoint = textView.BufferGraph.MapUpToSnapshot( point.GetPoint(point.TextBuffer.CurrentSnapshot), PointTrackingMode.Negative, PositionAffinity.Successor, textView.TextSnapshot); if (caretPoint.HasValue) { (textView as FrameworkElement)?.Focus(); textView.Caret.MoveTo(caretPoint.Value); } } foreach (var other in allTextViews) { if (other != textView) { peekService.Hide(other); } } }
/// <inheritdoc/> public ITrackingPoint Show(ITextView textView, ShowInlineCommentTag tag) { Guard.ArgumentNotNull(textView, nameof(textView)); Guard.ArgumentNotNull(tag, nameof(tag)); var projectionBuffer = textView.TextBuffer as IProjectionBuffer; var snapshot = textView.TextSnapshot; // If we're displaying a comment on a deleted line, then check if we're displaying in a // diff view in inline mode. If so, get the line from the left buffer. if (tag.DiffChangeType == DiffChangeType.Delete) { var diffModel = (textView as IWpfTextView)?.TextViewModel as IDifferenceTextViewModel; if (diffModel?.ViewType == DifferenceViewType.InlineView) { snapshot = diffModel.Viewer.DifferenceBuffer.LeftBuffer.CurrentSnapshot; } } var line = snapshot.GetLineFromLineNumber(tag.LineNumber); var trackingPoint = snapshot.CreateTrackingPoint(line.Start.Position, PointTrackingMode.Positive); ExpandCollapsedRegions(textView, line.Extent); peekBroker.TriggerPeekSession(textView, trackingPoint, InlineCommentPeekRelationship.Instance.Name); return(trackingPoint); }
/// <inheritdoc/> public ITrackingPoint Show(ITextView textView, ShowInlineCommentTag tag) { Guard.ArgumentNotNull(textView, nameof(textView)); Guard.ArgumentNotNull(tag, nameof(tag)); var lineAndtrackingPoint = GetLineAndTrackingPoint(textView, tag); var line = lineAndtrackingPoint.Item1; var trackingPoint = lineAndtrackingPoint.Item2; var options = new PeekSessionCreationOptions( textView, InlineCommentPeekRelationship.Instance.Name, trackingPoint, defaultHeight: 0); ExpandCollapsedRegions(textView, line.Extent); peekBroker.TriggerPeekSession(options); return(trackingPoint); }
/// <inheritdoc/> public ITrackingPoint Show(ITextView textView, ShowInlineCommentTag tag) { Guard.ArgumentNotNull(textView, nameof(textView)); Guard.ArgumentNotNull(tag, nameof(tag)); var lineAndtrackingPoint = GetLineAndTrackingPoint(textView, tag); var line = lineAndtrackingPoint.Item1; var trackingPoint = lineAndtrackingPoint.Item2; var options = new PeekSessionCreationOptions( textView, InlineCommentPeekRelationship.Instance.Name, trackingPoint, defaultHeight: 0); ExpandCollapsedRegions(textView, line.Extent); var session = peekBroker.TriggerPeekSession(options); var item = session.PeekableItems.OfType<InlineCommentPeekableItem>().FirstOrDefault(); item?.ViewModel.Close.Take(1).Subscribe(_ => session.Dismiss()); return trackingPoint; }