diff --git a/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/AsyncCompletionService.cs b/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/AsyncCompletionService.cs index bf78c22a4ce37..095231d5d9bb4 100644 --- a/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/AsyncCompletionService.cs +++ b/src/EditorFeatures/Core/Implementation/IntelliSense/Completion/AsyncCompletionService.cs @@ -87,10 +87,32 @@ private bool UseLegacyCompletion(ITextView textView, ITextBuffer subjectBuffer) { if (!_newCompletionAPIEnabled.HasValue) { - if (Workspace.TryGetWorkspace(subjectBuffer.AsTextContainer(), out var workspace)) + int userSetting = 0; + const string useAsyncCompletionOptionName = "UseAsyncCompletion"; + if (textView.Options.GlobalOptions.IsOptionDefined(useAsyncCompletionOptionName, localScopeOnly: false)) { - var experimentationService = workspace.Services.GetService(); - _newCompletionAPIEnabled = experimentationService.IsExperimentEnabled(WellKnownExperimentNames.CompletionAPI); + userSetting = textView.Options.GlobalOptions.GetOptionValue(useAsyncCompletionOptionName); + } + + // The meaning of the UseAsyncCompletion option definition's values: + // -1 - user disabled async completion + // 0 - no changes from the user; check the experimentation service for whether to use async completion + // 1 - user enabled async completion + if (userSetting == 1) + { + _newCompletionAPIEnabled = true; + } + else if (userSetting == -1) + { + _newCompletionAPIEnabled = false; + } + else + { + if (Workspace.TryGetWorkspace(subjectBuffer.AsTextContainer(), out var workspace)) + { + var experimentationService = workspace.Services.GetService(); + _newCompletionAPIEnabled = experimentationService.IsExperimentEnabled(WellKnownExperimentNames.CompletionAPI); + } } }