Skip to content

Commit

Permalink
Merge pull request #65903 from dotnet/merges/release/dev17.5-to-main
Browse files Browse the repository at this point in the history
Merge release/dev17.5 to main
  • Loading branch information
dotnet-bot authored Dec 9, 2022
2 parents 1100e56 + 9fc0d74 commit 28cc012
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.CodeAnalysis.Options;

namespace Microsoft.VisualStudio.LanguageServices.DocumentOutline
{
internal sealed class DocumentOutlineOptionsMetadata
{
private const string FeatureName = "DocumentOutlineOptions";

public static readonly Option2<bool> EnableDocumentOutline = new(FeatureName, nameof(EnableDocumentOutline), defaultValue: false,
storageLocation: new FeatureFlagStorageLocation("Roslyn.DocumentOutline"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ public int RemoveAdornments()
// that ReleaseOutline will be called on the old window before GetOutline is called for the new window.
int IVsDocOutlineProvider.GetOutline(out IntPtr phwnd, out IOleCommandTarget? ppCmdTarget)
{
var enabled = _globalOptions.GetOption(DocumentOutlineOptionsMetadata.EnableDocumentOutline);
if (!enabled)
{
phwnd = default;
ppCmdTarget = null;
return VSConstants.S_OK;
}

var languageServiceBroker = _languageService.Package.ComponentModel.GetService<ILanguageServiceBroker2>();
var threadingContext = _languageService.Package.ComponentModel.GetService<IThreadingContext>();
var asyncListenerProvider = _languageService.Package.ComponentModel.GetService<IAsynchronousOperationListenerProvider>();
Expand Down Expand Up @@ -270,17 +278,17 @@ int IVsDocOutlineProvider.ReleaseOutline(IntPtr hwnd, IOleCommandTarget pCmdTarg
var threadingContext = _languageService.Package.ComponentModel.GetService<IThreadingContext>();
threadingContext.ThrowIfNotOnUIThread();

// Assert that we are not attempting to double free the Document Outline Control and host.
Contract.ThrowIfNull(_documentOutlineViewHost);
Contract.ThrowIfNull(_documentOutlineControl);

_documentOutlineViewHost.SuspendLayout();
_documentOutlineControl.Dispose();
_documentOutlineControl = null;
_documentOutlineViewHost.Child = null;
_documentOutlineViewHost.Parent = null;
_documentOutlineViewHost.Dispose();
_documentOutlineViewHost = null;
if (_documentOutlineControl is not null &&
_documentOutlineViewHost is not null)
{
_documentOutlineViewHost.SuspendLayout();
_documentOutlineControl.Dispose();
_documentOutlineControl = null;
_documentOutlineViewHost.Child = null;
_documentOutlineViewHost.Parent = null;
_documentOutlineViewHost.Dispose();
_documentOutlineViewHost = null;
}

return VSConstants.S_OK;
}
Expand Down

0 comments on commit 28cc012

Please sign in to comment.