Skip to content

Commit

Permalink
Remove featureflag
Browse files Browse the repository at this point in the history
  • Loading branch information
genlu committed Mar 10, 2023
1 parent 6dd63b4 commit f92394a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ public async Task<VSCompletionContext> GetCompletionContextAsync(
// to still provide those items later before they are truly required.

var showCompletionItemFilters = _editorOptionsService.GlobalOptions.GetOption(CompletionViewOptionsStorage.ShowCompletionItemFilters, document.Project.Language);
var hideExpandedItemEnabled = _editorOptionsService.GlobalOptions.GetOption(CompletionViewOptionsStorage.HideExpandedItemsForShortFilterTextFeatureFlag);
var options = _editorOptionsService.GlobalOptions.GetCompletionOptions(document.Project.Language) with
{
UpdateImportCompletionCacheInBackground = true,
Expand Down Expand Up @@ -320,7 +319,7 @@ public async Task<VSCompletionContext> GetCompletionContextAsync(
// Now trigger and wait for core providers to return;
var (nonExpandedContext, nonExpandedCompletionList) = await GetCompletionContextWorkerAsync(session, document, trigger, triggerLocation,
options with { ExpandedCompletionBehavior = ExpandedCompletionMode.NonExpandedItemsOnly }, cancellationToken).ConfigureAwait(false);
UpdateSessionData(session, sessionData, nonExpandedCompletionList, triggerLocation, attemptHidingExpandedItems: hideExpandedItemEnabled);
UpdateSessionData(session, sessionData, nonExpandedCompletionList, triggerLocation, attemptHidingExpandedItems: true);

// If the core items are exclusive, we don't include expanded items.
if (sessionData.IsExclusive)
Expand All @@ -334,7 +333,7 @@ public async Task<VSCompletionContext> GetCompletionContextAsync(
{
// the task of expanded item is completed, get the result and combine it with result of non-expanded items.
var (expandedContext, expandedCompletionList) = await expandedItemsTask.ConfigureAwait(false);
UpdateSessionData(session, sessionData, expandedCompletionList, triggerLocation, attemptHidingExpandedItems: hideExpandedItemEnabled);
UpdateSessionData(session, sessionData, expandedCompletionList, triggerLocation, attemptHidingExpandedItems: true);
AsyncCompletionLogger.LogImportCompletionGetContext(isBlocking: false, delayed: false);

return CombineCompletionContext(session, nonExpandedContext, expandedContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,5 @@ internal sealed class CompletionViewOptionsStorage

public static readonly PerLanguageOption2<bool> BlockForCompletionItems =
new("block_for_completion_items", defaultValue: true);

public static readonly Option2<bool> HideExpandedItemsForShortFilterTextFeatureFlag =
new("dotnet_hide_expanded_items_for_short_filter_text_feature_flag", false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11262,7 +11262,7 @@ class Program
End Function

<WpfTheory, CombinatorialData>
Public Async Function TestAutoHidingExpandedItems(responsiveTypingEnabled As Boolean, featureFlagEnabled As Boolean) As Task
Public Async Function TestAutoHidingExpandedItems(responsiveTypingEnabled As Boolean) As Task
Using state = TestStateFactory.CreateCSharpTestState(
<Document>
$$
Expand All @@ -11272,7 +11272,7 @@ $$

Dim workspace = state.Workspace
workspace.GlobalOptions.SetGlobalOption(CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, LanguageNames.CSharp, True)
workspace.GlobalOptions.SetGlobalOption(CompletionViewOptionsStorage.HideExpandedItemsForShortFilterTextFeatureFlag, featureFlagEnabled)

' we don't auto hide expanded item if responsive completion is disabled
state.TextView.Options.SetOptionValue(DefaultOptions.ResponsiveCompletionOptionId, responsiveTypingEnabled)

Expand Down Expand Up @@ -11304,14 +11304,13 @@ $$
Assert.Equal(completionService.ExpandedCount, items.Where(Function(x) x.Flags.IsExpanded()).Count())
End If

Dim shouldHideExpandedItems = responsiveTypingEnabled And featureFlagEnabled
Dim typedChars = "Item"
For i = 0 To typedChars.Length - 1
Await state.SendTypeCharsAndWaitForUiRenderAsync(typedChars(i))
Dim items = state.GetCompletionItems()
Dim expandedCount As Integer

If (shouldHideExpandedItems And i <= ItemManager.MaximumFilterTextLengthToExcludeExpandedItems - 1) Then
If (responsiveTypingEnabled And i <= ItemManager.MaximumFilterTextLengthToExcludeExpandedItems - 1) Then
expandedCount = 0
Else
expandedCount = completionService.ExpandedCount
Expand All @@ -11331,47 +11330,6 @@ $$
End Using
End Function

<WpfFact>
Public Async Function DoNotHideExpandedItemsIfAllRegularFilteredOut() As Task
Using state = TestStateFactory.CreateCSharpTestState(
<Document>
$$
</Document>,
excludedTypes:={GetType(CSharpCompletionService.Factory)}.ToList(),
extraExportedTypes:={GetType(MockCompletionServiceFactory)}.ToList())

Dim workspace = state.Workspace
workspace.GlobalOptions.SetGlobalOption(CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, LanguageNames.CSharp, True)
workspace.GlobalOptions.SetGlobalOption(CompletionViewOptionsStorage.HideExpandedItemsForShortFilterTextFeatureFlag, True)
' we don't auto hide expanded item if responsive completion is disabled
state.TextView.Options.SetOptionValue(DefaultOptions.ResponsiveCompletionOptionId, True)

Dim completionService = DirectCast(workspace.Services.GetLanguageServices(LanguageNames.CSharp).GetRequiredService(Of CompletionService)(), MockCompletionServiceFactory.Service)

' we blocked the expanded item task, so only regular items in the list
Await state.SendTypeCharsAndWaitForUiRenderAsync("e")
state.AssertCompletionItemExpander(isAvailable:=True, isSelected:=False)
Dim items = state.GetCompletionItems()
Assert.Equal(completionService.RegularCount, items.Count)
Assert.False(items.Any(Function(i) i.Flags.IsExpanded()))

' make sure expanded item task completes
completionService.ExpandedItemsCheckpoint.Release()
Dim session = Await state.GetCompletionSession()
Dim sessionData = CompletionSessionData.GetOrCreateSessionData(session)
Assert.NotNull(sessionData.ExpandedItemsTask)
Await sessionData.ExpandedItemsTask

' now all "ItemRegular" should be filtered out, expanded items should be included
' even if the filter text ("ex") is shorter than ItemManager.MaximumFilterTextLengthToExcludeExpandedItems
Await state.SendTypeCharsAndWaitForUiRenderAsync("x")
items = state.GetCompletionItems()

Assert.Equal(completionService.ExpandedCount, items.Count)
Assert.Equal(completionService.ExpandedCount, items.Where(Function(x) x.Flags.IsExpanded()).Count())
End Using
End Function

<ExportLanguageServiceFactory(GetType(CompletionService), LanguageNames.CSharp), [Shared], PartNotDiscoverable>
Private Class MockCompletionServiceFactory
Implements ILanguageServiceFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ public bool TryFetch(LocalUserRegistryOptionPersister persister, OptionKey2 opti
#pragma warning disable CS0612 // Type or member is obsolete
{"dotnet_hide_advanced_members_in_completion", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Hide Advanced Auto List Members", vbKey: "TextEditor.Basic.Hide Advanced Auto List Members")},
#pragma warning restore
{"dotnet_hide_expanded_items_for_short_filter_text_feature_flag", new FeatureFlagStorage(@"Roslyn.HideExpandedItemsForShortFilterText")},
{"dotnet_highlight_matching_portions_of_completion_list_items", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.HighlightMatchingPortionsOfCompletionListItems")},
{"dotnet_show_completion_item_filters", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.ShowCompletionItemFilters")},
{"dotnet_show_completion_items_from_unimported_namespaces", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.ShowItemsFromUnimportedNamespaces")},
Expand Down

0 comments on commit f92394a

Please sign in to comment.