未验证 提交 0fd866e2 编写于 作者: G Gen Lu 提交者: GitHub

Merge pull request #39574 from genlu/EnableSortByMatching

Remove experiment for "sorting completion list by matching"
......@@ -8,7 +8,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.Experiments;
using Microsoft.CodeAnalysis.PatternMatching;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
......@@ -206,16 +205,11 @@ internal ItemManager(RecentItemsManager recentItemsManager)
return HandleAllItemsFilteredOut(reason, data.SelectedFilters, completionRules);
}
var experimentationService = document?.Project.Solution.Workspace.Services.GetService<IExperimentationService>();
if (experimentationService?.IsExperimentEnabled(WellKnownExperimentNames.SortCompletionListByMatch) == true)
{
// Sort the items by pattern matching results.
// Note that we want to preserve the original alphabetical order for items with same pattern match score,
// but `ArrayBuilder.Sort` isn't stable. Therefore we have to add a monotonically increasing integer
// to `MatchResult` to archieve this.
builder.Sort(MatchResult.SortingComparer);
}
// Sort the items by pattern matching results.
// Note that we want to preserve the original alphabetical order for items with same pattern match score,
// but `ArrayBuilder.Sort` isn't stable. Therefore we have to add a monotonically increasing integer
// to `MatchResult` to archieve this.
builder.Sort(MatchResult.SortingComparer);
var initialListOfItemsToBeIncluded = builder.ToImmutableAndFree();
......
......@@ -6028,7 +6028,7 @@ namespace NS2
<WorkItem(38253, "https://github.com/dotnet/roslyn/issues/38253")>
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function SortItemsByPatternMatchIfExperimentEnabled() As Task
Public Async Function SortItemsByPatternMatch() As Task
Using state = TestStateFactory.CreateCSharpTestState(
<Document>
namespace NS
......@@ -6058,9 +6058,6 @@ namespace NS
state.Workspace.Options = state.Workspace.Options _
.WithChangedOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, LanguageNames.CSharp, False)
Dim experimentService = state.GetService(Of TestExperimentationService)()
experimentService.SetExperimentOption(WellKnownExperimentNames.SortCompletionListByMatch, True)
state.SendTypeChars("task")
Await state.WaitForAsynchronousOperationsAsync()
Await state.AssertSelectedCompletionItem(displayText:="Task")
......@@ -6081,61 +6078,6 @@ namespace NS
End Using
End Function
<WorkItem(38253, "https://github.com/dotnet/roslyn/issues/38253")>
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function SortItemsAlphabeticallyIfExperimentDisabled() As Task
Using state = TestStateFactory.CreateCSharpTestState(
<Document>
namespace NS
{
class C
{
void M()
{
$$
}
}
class Task { }
class BTask1 { }
class BTask2 { }
class BTask3 { }
class Task1 { }
class Task2 { }
class Task3 { }
class ATaAaSaKa { }
} </Document>, extraExportedTypes:={GetType(TestExperimentationService)}.ToList())
state.Workspace.Options = state.Workspace.Options _
.WithChangedOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, LanguageNames.CSharp, False)
Dim experimentService = state.GetService(Of TestExperimentationService)()
experimentService.SetExperimentOption(WellKnownExperimentNames.SortCompletionListByMatch, False)
state.SendTypeChars("task")
Await state.WaitForAsynchronousOperationsAsync()
Await state.AssertSelectedCompletionItem(displayText:="Task")
Dim expectedOrder =
{
"ATaAaSaKa",
"BTask1",
"BTask2",
"BTask3",
"Task",
"Task1",
"Task2",
"Task3"
}
state.AssertItemsInOrder(expectedOrder)
End Using
End Function
Private Class MultipleChangeCompletionProvider
Inherits CompletionProvider
......
......@@ -31,7 +31,6 @@ internal static class WellKnownExperimentNames
public const string TypeImportCompletion = "Roslyn.TypeImportCompletion";
public const string TargetTypedCompletionFilter = "Roslyn.TargetTypedCompletionFilter";
public const string NativeEditorConfigSupport = "Roslyn.NativeEditorConfigSupport";
public const string SortCompletionListByMatch = "Roslyn.SortCompletionListByMatch";
// Syntactic LSP experiment treatments.
public const string SyntacticExp_LiveShareTagger_Remote = "Roslyn.LspTagger";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册