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

Fix reading VB editor options from ISettingsManager (17.4) #66398

Closed
wants to merge 1 commit into from
Closed
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 @@ -11,5 +11,5 @@ internal sealed class NavigationBarViewOptionsStorage
private const string FeatureName = "NavigationBarOptions";

public static readonly PerLanguageOption2<bool> ShowNavigationBar = new(
FeatureName, "ShowNavigationBar", defaultValue: true, new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Dropdown Bar"));
FeatureName, "ShowNavigationBar", defaultValue: true, new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Dropdown Bar", useEditorLanguageName: true));
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ internal sealed class SignatureHelpViewOptionsStorage
private const string FeatureName = "SignatureHelpOptions";

public static readonly PerLanguageOption2<bool> ShowSignatureHelp = new(
FeatureName, "ShowSignatureHelp", defaultValue: true, new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Auto List Params"));
FeatureName, "ShowSignatureHelp", defaultValue: true, new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Auto List Params", useEditorLanguageName: true));
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public static CompletionOptions GetCompletionOptions(this IGlobalOptionService o

public static readonly PerLanguageOption2<bool> HideAdvancedMembers = new(
"CompletionOptions", "HideAdvancedMembers", CompletionOptions.Default.HideAdvancedMembers,
new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Hide Advanced Auto List Members"));
new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Hide Advanced Auto List Members", useEditorLanguageName: true));

public static readonly PerLanguageOption2<bool> TriggerOnTyping = new(
"CompletionOptions", "TriggerOnTyping", CompletionOptions.Default.TriggerOnTyping,
new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Auto List Members"));
new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Auto List Members", useEditorLanguageName: true));

public static readonly PerLanguageOption2<bool> TriggerOnTypingLetters = new(nameof(CompletionOptions), nameof(TriggerOnTypingLetters), CompletionOptions.Default.TriggerOnTypingLetters,
storageLocation: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.TriggerOnTypingLetters"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ public Provider()
new(FeatureName, FormattingOptionGroups.IndentationAndSpacing, nameof(UseTabs), LineFormattingOptions.Default.UseTabs,
storageLocations: ImmutableArray.Create<OptionStorageLocation2>(
new EditorConfigStorageLocation<bool>("indent_style", s => s == "tab", isSet => isSet ? "tab" : "space"),
new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Insert Tabs")));
new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Insert Tabs", useEditorLanguageName: true)));

public static PerLanguageOption2<int> TabSize =
new(FeatureName, FormattingOptionGroups.IndentationAndSpacing, nameof(TabSize), LineFormattingOptions.Default.TabSize,
storageLocations: ImmutableArray.Create<OptionStorageLocation2>(
EditorConfigStorageLocation.ForInt32Option("tab_width"),
new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Tab Size")));
new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Tab Size", useEditorLanguageName: true)));

public static PerLanguageOption2<int> IndentationSize =
new(FeatureName, FormattingOptionGroups.IndentationAndSpacing, nameof(IndentationSize), LineFormattingOptions.Default.IndentationSize,
storageLocations: ImmutableArray.Create<OptionStorageLocation2>(
EditorConfigStorageLocation.ForInt32Option("indent_size"),
new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Indent Size")));
new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Indent Size", useEditorLanguageName: true)));

public static PerLanguageOption2<string> NewLine =
new(FeatureName, FormattingOptionGroups.NewLine, nameof(NewLine), LineFormattingOptions.Default.NewLine,
Expand All @@ -80,7 +80,7 @@ public Provider()

public static PerLanguageOption2<IndentStyle> SmartIndent { get; } =
new(FeatureName, FormattingOptionGroups.IndentationAndSpacing, nameof(SmartIndent), defaultValue: IndentationOptions.DefaultIndentStyle,
new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Indent Style"));
new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Indent Style", useEditorLanguageName: true));

#if !CODE_STYLE
internal static readonly ImmutableArray<IOption> Options = ImmutableArray.Create<IOption>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ namespace Microsoft.CodeAnalysis.Options;
internal abstract class ClientSettingsStorageLocation : OptionStorageLocation2
{
private readonly Func<string?, string> _keyNameFromLanguageName;
private readonly bool _useEditorLanguageName;

public ClientSettingsStorageLocation(string keyName)
=> _keyNameFromLanguageName = _ => keyName;
public ClientSettingsStorageLocation(string keyName, bool useEditorLanguageName)
{
_keyNameFromLanguageName = _ => keyName;
_useEditorLanguageName = useEditorLanguageName;
}

/// <summary>
/// Creates a <see cref="ClientSettingsStorageLocation"/> that has different key names for different languages.
Expand All @@ -39,7 +43,7 @@ public string GetKeyNameForLanguage(string? languageName)
keyName = keyName.Replace("%LANGUAGE%", languageName switch
{
LanguageNames.CSharp => "CSharp",
LanguageNames.VisualBasic => "VisualBasic",
LanguageNames.VisualBasic => _useEditorLanguageName ? "Basic" : "VisualBasic",
_ => languageName // handles F#, TypeScript and Xaml
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal sealed class LocalClientSettingsStorageLocation : ClientSettingsStorage
public override bool IsMachineLocal => true;

public LocalClientSettingsStorageLocation(string keyName)
: base(keyName)
: base(keyName, useEditorLanguageName: false)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ internal sealed class RoamingProfileStorageLocation : ClientSettingsStorageLocat
{
public override bool IsMachineLocal => false;

public RoamingProfileStorageLocation(string keyName)
: base(keyName)
public RoamingProfileStorageLocation(string keyName, bool useEditorLanguageName = false)
: base(keyName, useEditorLanguageName)
{
}

Expand Down