-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use global options for async completion #32045
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<IExperimentationService>(); | ||
_newCompletionAPIEnabled = experimentationService.IsExperimentEnabled(WellKnownExperimentNames.CompletionAPI); | ||
userSetting = textView.Options.GlobalOptions.GetOptionValue<int>(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<IExperimentationService>(); | ||
_newCompletionAPIEnabled = experimentationService.IsExperimentEnabled(WellKnownExperimentNames.CompletionAPI); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if there is a chance of the if statement failing, consider setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As soon as we get a workspace and an experimentation service, we should set _newCompletionAPIEnabled to a value. We should try checking unit this. Not? In reply to: 245185354 [](ancestors = 245185354) |
||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't really understand where teh 1 and -1 values came from... How do you know it will be those values. Do we have code elsewhere that sets these? If so, can we define constants somewhere that we can share between the reading/writing code? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Thank you, @CyrusNajmabadi! Let me add a comment #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It corresponds to values of a three-state checkbox #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and it is an convention used in VS settings #Resolved