From 6ff260bbaa4595422582d8a4a4dc4a124f351e33 Mon Sep 17 00:00:00 2001 From: Gen Lu Date: Fri, 6 Sep 2019 15:49:35 -0700 Subject: [PATCH] Don't crash if no experiment service is found Fix unit tests --- .../IntelliSense/AsyncCompletion/ItemManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/ItemManager.cs b/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/ItemManager.cs index 251b0cb1f54..0b455245bd6 100644 --- a/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/ItemManager.cs +++ b/src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/ItemManager.cs @@ -228,9 +228,9 @@ internal ItemManager(RecentItemsManager recentItemsManager) return HandleAllItemsFilteredOut(reason, data.SelectedFilters, completionRules); } - var experimentationService = document.Project.Solution.Workspace.Services.GetService(); + var experimentationService = document?.Project.Solution.Workspace.Services.GetService(); - var initialListOfItemsToBeIncluded = experimentationService.IsExperimentEnabled(WellKnownExperimentNames.SortCompletionListByMatch) + var initialListOfItemsToBeIncluded = experimentationService?.IsExperimentEnabled(WellKnownExperimentNames.SortCompletionListByMatch) == true // Need a stable sorting algorithm to preserve the original order for items with same pattern match score. ? builder.OrderBy(new NullablePatternMatchComparer()).ToImmutableArray() : builder.ToImmutable(); -- GitLab