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

Merge release/dev17.0 to main #55303

Merged
merged 2 commits into from
Jul 31, 2021
Merged
Show file tree
Hide file tree
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 @@ -43,8 +43,8 @@ public void ExecuteCommand(PasteCommandArgs args, Action nextCommandHandler, Com
// Check that the feature is enabled before doing any work
var optionValue = args.SubjectBuffer.GetOptionalFeatureOnOffOption(FeatureOnOffOptions.AddImportsOnPaste);

// If the feature is explicitly disabled we can exit early
if (optionValue.HasValue && !optionValue.Value)
// If the feature is not explicitly enabled we can exit early
if (optionValue != true)
{
nextCommandHandler();
return;
Expand All @@ -71,7 +71,7 @@ public void ExecuteCommand(PasteCommandArgs args, Action nextCommandHandler, Com

try
{
ExecuteCommandWorker(args, executionContext, optionValue, trackingSpan);
ExecuteCommandWorker(args, executionContext, trackingSpan);
}
catch (OperationCanceledException)
{
Expand All @@ -84,7 +84,6 @@ public void ExecuteCommand(PasteCommandArgs args, Action nextCommandHandler, Com
private void ExecuteCommandWorker(
PasteCommandArgs args,
CommandExecutionContext executionContext,
bool? optionValue,
ITrackingSpan trackingSpan)
{
if (!args.SubjectBuffer.CanApplyChangeDocumentToWorkspace())
Expand Down Expand Up @@ -114,14 +113,6 @@ private void ExecuteCommandWorker(
return;
}

// Enable by default unless the user has explicitly disabled in the settings
var disabled = optionValue.HasValue && !optionValue.Value;

if (disabled)
{
return;
}

using var _ = executionContext.OperationContext.AddScope(allowCancellation: true, DialogText);
var cancellationToken = executionContext.OperationContext.UserCancellationToken;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public AdvancedOptionPageControl(OptionStore optionStore, IComponentModel compon
BindToOption(SuggestForTypesInNuGetPackages, SymbolSearchOptions.SuggestForTypesInNuGetPackages, LanguageNames.CSharp);
BindToOption(AddUsingsOnPaste, FeatureOnOffOptions.AddImportsOnPaste, LanguageNames.CSharp, () =>
{
// This option used to be backed by an experimentation flag but is now enabled by default.
// This option used to be backed by an experimentation flag but is no longer.
// Having the option still a bool? keeps us from running into storage related issues,
// but if the option was stored as null we want it to be enabled by default
return true;
// but if the option was stored as null we want it to respect this default
return false;
});

BindToOption(Split_string_literals_on_enter, SplitStringLiteralOptions.Enabled, LanguageNames.CSharp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void Main(string[] args)
}

[WpfFact, Trait(Traits.Feature, Traits.Features.AddMissingImports)]
public void VerifyEnabledWithNull()
public void VerifyDisabledWithNull()
{
var project = new Microsoft.VisualStudio.IntegrationTest.Utilities.Common.ProjectUtils.Project(ProjectName);
VisualStudio.SolutionExplorer.AddFile(project, "Example.cs", contents: @"
Expand All @@ -85,7 +85,6 @@ static void Main(string[] args)

VisualStudio.Editor.Verify.TextContains(@"
using System;
using System.Threading.Tasks;

class Program
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
BindToOption(SuggestForTypesInNuGetPackages, SymbolSearchOptions.SuggestForTypesInNuGetPackages, LanguageNames.VisualBasic)
BindToOption(AddMissingImportsOnPaste, FeatureOnOffOptions.AddImportsOnPaste, LanguageNames.VisualBasic,
Function()
' This option used to be backed by an experimentation flag but Is now enabled by default.
' This option used to be backed by an experimentation flag but Is no longer.
' Having the option still a bool? keeps us from running into storage related issues,
' but if the option was stored as null we want it to be enabled by default
Return True
' but if the option was stored as null we want it to respect this default
Return False
End Function)

' Highlighting
Expand Down