Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Center the symbol being navigated to when navigating through doc-outline #76326

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Outlining;
using InternalUtilities = Microsoft.Internal.VisualStudio.PlatformUI.Utilities;
using IOleCommandTarget = Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget;
Expand Down Expand Up @@ -294,9 +295,13 @@ private void SymbolTree_SourceUpdated(object sender, DataTransferEventArgs e)
try
{
var textView = _viewTracker.GetActiveView();

// Attempt to move the item to the center of the view. The user selected the item explicitly, and this
// gives them a consistent location they can expect to see the result at.
textView.TryMoveCaretToAndEnsureVisible(
symbolModel.Data.SelectionRangeSpan.TranslateTo(textView.TextSnapshot, SpanTrackingMode.EdgeInclusive).Start,
_outliningManagerService);
_outliningManagerService,
EnsureSpanVisibleOptions.AlwaysCenter);
}
finally
{
Expand Down
Loading