Skip to content
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 @@ -116,6 +116,12 @@ private System.Threading.Tasks.Task OnSettingChangedAsync(object sender, Propert
return stringArray.ToImmutableArray();
}

if (optionKey.Option.Type == typeof(int) &&
_settingManager.TryGetValue(storageKey, out int intValue) == GetValueResult.Success)
{
return intValue;
}
Comment on lines +119 to +123

@Youssef1313 Youssef1313 Nov 12, 2022 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we instead update the following line to match the type stored in _settingsManager?

EditorConfigStorageLocation.ForInt32Option("indent_size"),

Edit: This change might not be necessary with the suggestion in #65382 (review)

@tmat tmat Nov 12, 2022 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think so. The fact that the option is stored as Int64 in VS setting is a VS-specific quirk. Quite odd, since there is no reason for it to be 64 bit.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@tmat Then what about the more generalized approach suggested in #65382 (review)?

This will ensure that no such issues exist whatever the type of option is.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will follow up on that later on: #65394


if (_settingManager.TryGetValue(storageKey, out object value) == GetValueResult.Success)
{
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ public Provider()
new(FeatureName, FormattingOptionGroups.NewLine, nameof(InsertFinalNewLine), DocumentFormattingOptions.Default.InsertFinalNewLine,
storageLocation: EditorConfigStorageLocation.ForBoolOption("insert_final_newline"));

public static PerLanguageOption2<FormattingOptions2.IndentStyle> SmartIndent { get; } =
new(FeatureName, FormattingOptionGroups.IndentationAndSpacing, nameof(SmartIndent), defaultValue: IndentationOptions.DefaultIndentStyle);
public static PerLanguageOption2<IndentStyle> SmartIndent { get; } =
new(FeatureName, FormattingOptionGroups.IndentationAndSpacing, nameof(SmartIndent), defaultValue: IndentationOptions.DefaultIndentStyle,
new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Indent Style"));
Comment on lines +81 to +83

@Youssef1313 Youssef1313 Nov 12, 2022 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand how roaming storage location is useful here?
This doesn't seem to be exposed in Tools → Options, and it's not in AutomationObject.

So its value will always remain DefaultIndentStyle and it is never fetched/persisted through import/export.

Anything I'm missing? I'm curious to know the user-visible effect of this change if you noticed any.

@tmat tmat Nov 12, 2022 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The option is read from global options here: https://sourceroslyn.io/#Microsoft.CodeAnalysis.LanguageServer.Protocol/Features/Options/IndentationOptionsStorage.cs,21

Global options end up calling VisualStudioSettingsOptionPersister to read the option from VS settings, but that only happens if it has the storage.

The option is owned by the VS platform, not Roslyn. Roslyn does not set it nor has any UI that exposes it. It just needs to read it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @tmat @arkalyanms for clarifying.


#if !CODE_STYLE
internal static readonly ImmutableArray<IOption> Options = ImmutableArray.Create<IOption>(
Expand Down