Repository: dotnet/roslyn
File: src/EditorFeatures/Core/Shared/Extensions/ITextViewExtensions.cs (C#)

Code before:

    public static bool TryMoveCaretToAndEnsureVisible(this ITextView textView, VirtualSnapshotPoint point, IOutliningManagerService? outliningManagerService = null, EnsureSpanVisibleOptions ensureSpanVisibleOptions = EnsureSpanVisibleOptions.None)
    {
        if (textView.IsClosed)
        {
            return false;
        }

        var pointInView = textView.GetPositionInView(point.Position);

        if (!pointInView.HasValue)
        {
            return false;
        }

        // If we were given an outlining service, we need to expand any outlines first, or else
        // the Caret.MoveTo won't land in the correct location if our target is inside a
        // collapsed outline.
        if (outliningManagerService != null)
        {
            var outliningManager = outliningManagerService.GetOutliningManager(textView);

            outliningManager?.ExpandAll(new SnapshotSpan(pointInView.Value, length: 0), match: _ => true);
        }

        // Moving caret doesn't clear previous selection so we need to clear it manually to avoid modifying previously selected text
        textView.Selection.Clear();

        var newPosition = textView.Caret.MoveTo(new VirtualSnapshotPoint(pointInView.Value, point.VirtualSpaces));

        // We use the caret's position in the view's current snapshot here in case something 
        // changed text in response to a caret move (e.g. line commit)
        var spanInView = new SnapshotSpan(newPosition.BufferPosition, 0);
        textView.ViewScroller.EnsureSpanVisible(spanInView, ensureSpanVisibleOptions);

        return true;
    }

    /// <summary>
    /// Gets or creates a view property that would go away when view gets closed
    /// </summary>
    public static TProperty GetOrCreateAutoClosingProperty<TProperty, TTextView>(
        this TTextView textView,
        Func<TTextView, TProperty> valueCreator) where TTextView : ITextView
    {
        return textView.GetOrCreateAutoClosingProperty(typeof(TProperty), valueCreator);
    }

    /// <summary>
    /// Gets or creates a view property that would go away when view gets closed
    /// </summary>

Review comment (suggestion):
```suggestion
        // Moving caret doesn't clear previous selection so we need to clear it manually
```

That last bit didn't make sense in context.

Code after:

    public static bool TryMoveCaretToAndEnsureVisible(this ITextView textView, VirtualSnapshotPoint point, IOutliningManagerService? outliningManagerService = null, EnsureSpanVisibleOptions ensureSpanVisibleOptions = EnsureSpanVisibleOptions.None)
    {
        if (textView.IsClosed)
        {
            return false;
        }

        var pointInView = textView.GetPositionInView(point.Position);

        if (!pointInView.HasValue)
        {
            return false;
        }

        // If we were given an outlining service, we need to expand any outlines first, or else
        // the Caret.MoveTo won't land in the correct location if our target is inside a
        // collapsed outline.
        if (outliningManagerService != null)
        {
            var outliningManager = outliningManagerService.GetOutliningManager(textView);

            outliningManager?.ExpandAll(new SnapshotSpan(pointInView.Value, length: 0), match: _ => true);
        }

        // Moving caret doesn't clear previous selection so we need to clear it manually
        textView.Selection.Clear();

        var newPosition = textView.Caret.MoveTo(new VirtualSnapshotPoint(pointInView.Value, point.VirtualSpaces));

        // We use the caret's position in the view's current snapshot here in case something 
        // changed text in response to a caret move (e.g. line commit)
        var spanInView = new SnapshotSpan(newPosition.BufferPosition, 0);
        textView.ViewScroller.EnsureSpanVisible(spanInView, ensureSpanVisibleOptions);

        return true;
    }

    /// <summary>
    /// Gets or creates a view property that would go away when view gets closed
    /// </summary>
    public static TProperty GetOrCreateAutoClosingProperty<TProperty, TTextView>(
        this TTextView textView,
        Func<TTextView, TProperty> valueCreator) where TTextView : ITextView
    {
        return textView.GetOrCreateAutoClosingProperty(typeof(TProperty), valueCreator);
    }

    /// <summary>
    /// Gets or creates a view property that would go away when view gets closed
    /// </summary>