Skip to content

Commit

Permalink
Merge pull request #68088 from sharwell/document-outline
Browse files Browse the repository at this point in the history
Enable document outline by default
  • Loading branch information
sharwell authored May 15, 2023
2 parents 32df870 + 1c883d9 commit 69f87c6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,12 @@ public AdvancedOptionPageControl(OptionStore optionStore, IComponentModel compon
BindToOption(AutomaticallyOpenStackTraceExplorer, StackTraceExplorerOptionsStorage.OpenOnFocus);

// Document Outline
BindToOption(EnableDocumentOutline, DocumentOutlineOptionsStorage.EnableDocumentOutline);
BindToOption(EnableDocumentOutline, DocumentOutlineOptionsStorage.EnableDocumentOutline, () =>
{
// If the option has not been set by the user, check if the option is disabled from experimentation. If
// so, default to reflect that.
return !optionStore.GetOption(DocumentOutlineOptionsStorage.DisableDocumentOutlineFeatureFlag);
});
}

// Since this dialog is constructed once for the lifetime of the application and VS Theme can be changed after the application has started,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ namespace Microsoft.VisualStudio.LanguageServices.DocumentOutline
/// </summary>
internal sealed class DocumentOutlineOptionsStorage
{
public static readonly Option2<bool> EnableDocumentOutline = new("visual_studio_enable_document_outline", defaultValue: false);
public static readonly Option2<bool?> EnableDocumentOutline = new("visual_studio_enable_document_outline", defaultValue: null);

public static readonly Option2<bool> DisableDocumentOutlineFeatureFlag = new("visual_studio_disable_document_outline_feature_flag", defaultValue: false);

public static readonly Option2<SortOption> DocumentOutlineSortOrder = new("visual_studio_document_outline_sort_order", defaultValue: SortOption.Location);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private void SymbolTreeItem_Selected(object sender, RoutedEventArgs e)
if (e.OriginalSource is TreeViewItem item)
{
double renderHeight;
if (item.IsExpanded)
if (item.IsExpanded && item.HasItems)
{
// The first child is a container. Inside the container are three children:
// 1. The expander
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ private void GetOutline(out IntPtr phwnd)
{
phwnd = default;

var enabled = _globalOptions.GetOption(DocumentOutlineOptionsStorage.EnableDocumentOutline);
var enabled = _globalOptions.GetOption(DocumentOutlineOptionsStorage.EnableDocumentOutline)
?? !_globalOptions.GetOption(DocumentOutlineOptionsStorage.DisableDocumentOutlineFeatureFlag);
if (!enabled)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ public bool TryFetch(LocalUserRegistryOptionPersister persister, OptionKey2 opti
{"csharp_split_string_literal_on_return", new RoamingProfileStorage("TextEditor.CSharp.Specific.SplitStringLiterals")},
{"visual_studio_open_stack_trace_explorer_on_focus", new RoamingProfileStorage("StackTraceExplorer.Options.OpenOnFocus")},
{"visual_studio_enable_document_outline", new RoamingProfileStorage(@"DocumentOutline.Enable")},
{"visual_studio_disable_document_outline_feature_flag", new FeatureFlagStorage(@"DocumentOutline.DisableFeature")},
{"visual_studio_document_outline_sort_order", new RoamingProfileStorage(@"DocumentOutline.SortOrder")},
{"visual_studio_enable_symbol_search", new LocalUserProfileStorage(@"Roslyn\Features\SymbolSearch", "Enabled")},
{"dotnet_search_nuget_packages", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.SuggestForTypesInNuGetPackages")},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,12 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
BindToOption(IncludeGlobalImports, InheritanceMarginOptionsStorage.InheritanceMarginIncludeGlobalImports, LanguageNames.VisualBasic)

' Document Outline
BindToOption(EnableDocumentOutline, DocumentOutlineOptionsStorage.EnableDocumentOutline)
BindToOption(EnableDocumentOutline, DocumentOutlineOptionsStorage.EnableDocumentOutline,
Function()
' If the option has Not been set by the user, check if the option is disabled from experimentation.
' If so, default to reflect that.
Return Not optionStore.GetOption(DocumentOutlineOptionsStorage.DisableDocumentOutlineFeatureFlag)
End Function)
End Sub

' Since this dialog is constructed once for the lifetime of the application and VS Theme can be changed after the application has started,
Expand Down

0 comments on commit 69f87c6

Please sign in to comment.