Skip to content

Commit

Permalink
Fix failure to expand outlining regions during Document Outline navig…
Browse files Browse the repository at this point in the history
…ation

Fixes #69902
  • Loading branch information
sharwell committed Sep 12, 2023
1 parent 8ef6199 commit b7f2177
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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.Outlining;
using InternalUtilities = Microsoft.Internal.VisualStudio.PlatformUI.Utilities;
using IOleCommandTarget = Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget;
using OLECMD = Microsoft.VisualStudio.OLE.Interop.OLECMD;
Expand All @@ -34,6 +35,7 @@ internal sealed partial class DocumentOutlineView : UserControl, IOleCommandTarg
{
private readonly IThreadingContext _threadingContext;
private readonly IGlobalOptionService _globalOptionService;
private readonly IOutliningManagerService _outliningManagerService;
private readonly VsCodeWindowViewTracker _viewTracker;
private readonly DocumentOutlineViewModel _viewModel;
private readonly IVsToolbarTrayHost _toolbarTrayHost;
Expand All @@ -44,11 +46,13 @@ public DocumentOutlineView(
IVsWindowSearchHostFactory windowSearchHostFactory,
IThreadingContext threadingContext,
IGlobalOptionService globalOptionService,
IOutliningManagerService outliningManagerService,
VsCodeWindowViewTracker viewTracker,
DocumentOutlineViewModel viewModel)
{
_threadingContext = threadingContext;
_globalOptionService = globalOptionService;
_outliningManagerService = outliningManagerService;
_viewTracker = viewTracker;
_viewModel = viewModel;

Expand Down Expand Up @@ -289,7 +293,8 @@ private void SymbolTree_SourceUpdated(object sender, DataTransferEventArgs e)
{
var textView = _viewTracker.GetActiveView();
textView.TryMoveCaretToAndEnsureVisible(
symbolModel.Data.SelectionRangeSpan.TranslateTo(textView.TextSnapshot, SpanTrackingMode.EdgeInclusive).Start);
symbolModel.Data.SelectionRangeSpan.TranslateTo(textView.TextSnapshot, SpanTrackingMode.EdgeInclusive).Start,
_outliningManagerService);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Outlining;
using Microsoft.VisualStudio.TextManager.Interop;
using Roslyn.Utilities;

Expand Down Expand Up @@ -264,14 +265,15 @@ private void GetOutline(out IntPtr phwnd)
var asyncListenerProvider = _languageService.Package.ComponentModel.GetService<IAsynchronousOperationListenerProvider>();
var asyncListener = asyncListenerProvider.GetListener(FeatureAttribute.DocumentOutline);
var editorAdaptersFactoryService = _languageService.Package.ComponentModel.GetService<IVsEditorAdaptersFactoryService>();
var outliningManagerService = _languageService.Package.ComponentModel.GetService<IOutliningManagerService>();

// Assert that the previous Document Outline Control and host have been freed.
Contract.ThrowIfFalse(_documentOutlineView is null);
Contract.ThrowIfFalse(_documentOutlineViewHost is null);

var viewTracker = new VsCodeWindowViewTracker(_codeWindow, threadingContext, editorAdaptersFactoryService);
_documentOutlineView = new DocumentOutlineView(
uiShell, windowSearchHostFactory, threadingContext, _globalOptions, viewTracker,
uiShell, windowSearchHostFactory, threadingContext, _globalOptions, outliningManagerService, viewTracker,
new DocumentOutlineViewModel(threadingContext, viewTracker, languageServiceBroker, asyncListener));

_documentOutlineViewHost = new ElementHost
Expand Down

0 comments on commit b7f2177

Please sign in to comment.