Skip to content
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

Merged
merged 4 commits into from
Jan 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Jan 4, 2019

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

Copy link
Contributor Author

@ivanbasov ivanbasov Jan 4, 2019

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

Copy link
Contributor

@AmadeusW AmadeusW Jan 4, 2019

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

Copy link
Contributor

@AmadeusW AmadeusW Jan 4, 2019

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

else
{
if (Workspace.TryGetWorkspace(subjectBuffer.AsTextContainer(), out var workspace))
{
var experimentationService = workspace.Services.GetService<IExperimentationService>();
_newCompletionAPIEnabled = experimentationService.IsExperimentEnabled(WellKnownExperimentNames.CompletionAPI);
Copy link
Contributor

@AmadeusW AmadeusW Jan 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is a chance of the if statement failing, consider setting _newCompletionAPIEnabled to something so that we avoid repeating work. If this won't fail, though, don't worry about it. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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)

}
}
}

Expand Down