diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/AutoInsert/OnAutoInsertEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/AutoInsert/OnAutoInsertEndpoint.cs index bdad71ad41b..d71c507cb57 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/AutoInsert/OnAutoInsertEndpoint.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/AutoInsert/OnAutoInsertEndpoint.cs @@ -143,7 +143,7 @@ public void ApplyCapabilities(VSInternalServerCapabilities serverCapabilities, V // Therefore we are just going to no-op if the user has turned off on type formatting. Maybe one day we can make this // smarter, but at least the user can always turn the setting back on, type their "///", and turn it back off, without // having to restart VS. Not the worst compromise (hopefully!) - if (!_optionsMonitor.CurrentValue.Formatting.IsOnTypeEnabled()) + if (!_optionsMonitor.CurrentValue.FormatOnType) { Logger.LogInformation($"Formatting on type disabled, so auto insert is a no-op for C#."); return SpecializedTasks.Null(); diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultRazorConfigurationService.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultRazorConfigurationService.cs index d7d3abcab15..6010dde3ebd 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultRazorConfigurationService.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/DefaultRazorConfigurationService.cs @@ -96,10 +96,10 @@ internal RazorLSPOptions BuildOptions(JsonObject[] result) } else { - ExtractVSCodeOptions(result, out var formatting, out var autoClosingTags, out var commitElementsWithSpace, out var codeBlockBraceOnNextLine); + ExtractVSCodeOptions(result, out var enableFormatting, out var autoClosingTags, out var commitElementsWithSpace, out var codeBlockBraceOnNextLine); return RazorLSPOptions.Default with { - Formatting = formatting, + EnableFormatting = enableFormatting, AutoClosingTags = autoClosingTags, CommitElementsWithSpace = commitElementsWithSpace, CodeBlockBraceOnNextLine = codeBlockBraceOnNextLine @@ -109,7 +109,7 @@ internal RazorLSPOptions BuildOptions(JsonObject[] result) private void ExtractVSCodeOptions( JsonObject[] result, - out FormattingFlags formatting, + out bool enableFormatting, out bool autoClosingTags, out bool commitElementsWithSpace, out bool codeBlockBraceOnNextLine) @@ -117,7 +117,7 @@ private void ExtractVSCodeOptions( var razor = result[0]; var html = result[1]; - formatting = RazorLSPOptions.Default.Formatting; + enableFormatting = RazorLSPOptions.Default.EnableFormatting; autoClosingTags = RazorLSPOptions.Default.AutoClosingTags; codeBlockBraceOnNextLine = RazorLSPOptions.Default.CodeBlockBraceOnNextLine; // Deliberately not using the "default" here because we want a different default for VS Code, as @@ -130,15 +130,7 @@ private void ExtractVSCodeOptions( if (parsedFormat.TryGetPropertyValue("enable", out var parsedEnableFormatting) && parsedEnableFormatting is not null) { - var formattingEnabled = GetObjectOrDefault(parsedEnableFormatting, formatting.IsEnabled()); - if (formattingEnabled) - { - formatting |= FormattingFlags.Enabled; - } - else - { - formatting = FormattingFlags.Disabled; - } + enableFormatting = GetObjectOrDefault(parsedEnableFormatting, enableFormatting); } if (parsedFormat.TryGetPropertyValue("codeBlockBraceOnNextLine", out var parsedCodeBlockBraceOnNextLine) && diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentFormattingEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentFormattingEndpoint.cs index 6358afb3c34..1564a8d4129 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentFormattingEndpoint.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentFormattingEndpoint.cs @@ -37,7 +37,7 @@ public TextDocumentIdentifier GetTextDocumentIdentifier(DocumentFormattingParams public async Task HandleRequestAsync(DocumentFormattingParams request, RazorRequestContext requestContext, CancellationToken cancellationToken) { - if (!_optionsMonitor.CurrentValue.Formatting.IsEnabled()) + if (!_optionsMonitor.CurrentValue.EnableFormatting) { return null; } diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentOnTypeFormattingEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentOnTypeFormattingEndpoint.cs index df1062b30f7..04c740f1e6e 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentOnTypeFormattingEndpoint.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentOnTypeFormattingEndpoint.cs @@ -49,13 +49,13 @@ public TextDocumentIdentifier GetTextDocumentIdentifier(DocumentOnTypeFormatting { _logger.LogInformation($"Starting OnTypeFormatting request for {request.TextDocument.Uri}."); - if (!_optionsMonitor.CurrentValue.Formatting.IsEnabled()) + if (!_optionsMonitor.CurrentValue.EnableFormatting) { _logger.LogInformation($"Formatting option disabled."); return null; } - if (!_optionsMonitor.CurrentValue.Formatting.IsOnTypeEnabled()) + if (!_optionsMonitor.CurrentValue.FormatOnType) { _logger.LogInformation($"Formatting on type disabled."); return null; diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentRangeFormattingEndpoint.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentRangeFormattingEndpoint.cs index da8823a0f2a..7ba97f9f9fb 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentRangeFormattingEndpoint.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Formatting/DocumentRangeFormattingEndpoint.cs @@ -37,7 +37,7 @@ public TextDocumentIdentifier GetTextDocumentIdentifier(DocumentRangeFormattingP public async Task HandleRequestAsync(DocumentRangeFormattingParams request, RazorRequestContext requestContext, CancellationToken cancellationToken) { - if (!_optionsMonitor.CurrentValue.Formatting.IsEnabled()) + if (!_optionsMonitor.CurrentValue.EnableFormatting) { return null; } @@ -54,16 +54,6 @@ public TextDocumentIdentifier GetTextDocumentIdentifier(DocumentRangeFormattingP return null; } - if (request.Options.OtherOptions is not null && - request.Options.OtherOptions.TryGetValue("fromPaste", out var fromPasteObj) && - fromPasteObj is bool fromPaste) - { - if (fromPaste && !_optionsMonitor.CurrentValue.Formatting.IsOnPasteEnabled()) - { - return null; - } - } - var options = RazorFormattingOptions.From(request.Options, _optionsMonitor.CurrentValue.CodeBlockBraceOnNextLine); var htmlChanges = await _htmlFormatter.GetDocumentFormattingEditsAsync(documentContext.Snapshot, documentContext.Uri, request.Options, cancellationToken).ConfigureAwait(false); diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/FormattingFlagExtensions.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/FormattingFlagExtensions.cs deleted file mode 100644 index 0ac02c7ba6c..00000000000 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/FormattingFlagExtensions.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the MIT license. See License.txt in the project root for license information. - -namespace Microsoft.AspNetCore.Razor.LanguageServer.Hosting; - -internal static class FormattingFlagExtensions -{ - public static bool IsEnabled(this FormattingFlags flags) - => flags.IsFlagSet(FormattingFlags.Enabled); - - public static bool IsOnTypeEnabled(this FormattingFlags flags) - => flags.IsEnabled() && flags.IsFlagSet(FormattingFlags.OnType); - - public static bool IsOnPasteEnabled(this FormattingFlags flags) - => flags.IsEnabled() && flags.IsFlagSet(FormattingFlags.OnPaste); -} diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/FormattingFlags.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/FormattingFlags.cs deleted file mode 100644 index b14073c22e3..00000000000 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/FormattingFlags.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the MIT license. See License.txt in the project root for license information. - -using System; - -namespace Microsoft.AspNetCore.Razor.LanguageServer.Hosting; - -[Flags] -internal enum FormattingFlags -{ - Disabled = 0, - Enabled = 1, - OnPaste = 1 << 1, - OnType = 1 << 2, - All = Enabled | OnPaste | OnType -}; diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/RazorLSPOptions.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/RazorLSPOptions.cs index c8d1a284810..1931a4a1055 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/RazorLSPOptions.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/RazorLSPOptions.cs @@ -1,29 +1,30 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the MIT license. See License.txt in the project root for license information. -using System; using Microsoft.CodeAnalysis.Razor.Settings; namespace Microsoft.AspNetCore.Razor.LanguageServer.Hosting; internal record RazorLSPOptions( - FormattingFlags Formatting, + bool EnableFormatting, bool AutoClosingTags, bool InsertSpaces, int TabSize, bool AutoShowCompletion, bool AutoListParams, + bool FormatOnType, bool AutoInsertAttributeQuotes, bool ColorBackground, bool CodeBlockBraceOnNextLine, bool CommitElementsWithSpace) { - public readonly static RazorLSPOptions Default = new(Formatting: FormattingFlags.All, + public readonly static RazorLSPOptions Default = new(EnableFormatting: true, AutoClosingTags: true, AutoListParams: true, InsertSpaces: true, TabSize: 4, AutoShowCompletion: true, + FormatOnType: true, AutoInsertAttributeQuotes: true, ColorBackground: false, CodeBlockBraceOnNextLine: false, @@ -34,30 +35,15 @@ internal record RazorLSPOptions( /// not defined in client settings. /// internal static RazorLSPOptions From(ClientSettings settings) - => new(GetFormattingFlags(settings), + => new(Default.EnableFormatting, settings.AdvancedSettings.AutoClosingTags, !settings.ClientSpaceSettings.IndentWithTabs, settings.ClientSpaceSettings.IndentSize, settings.ClientCompletionSettings.AutoShowCompletion, settings.ClientCompletionSettings.AutoListParams, + settings.AdvancedSettings.FormatOnType, settings.AdvancedSettings.AutoInsertAttributeQuotes, settings.AdvancedSettings.ColorBackground, settings.AdvancedSettings.CodeBlockBraceOnNextLine, settings.AdvancedSettings.CommitElementsWithSpace); - - private static FormattingFlags GetFormattingFlags(ClientSettings settings) - { - var flags = FormattingFlags.Enabled; - if (settings.AdvancedSettings.FormatOnPaste) - { - flags |= FormattingFlags.OnPaste; - } - - if (settings.AdvancedSettings.FormatOnType) - { - flags |= FormattingFlags.OnType; - } - - return flags; - } } diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Settings/ClientSettings.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Settings/ClientSettings.cs index f0e9036a619..568b7f38da7 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Settings/ClientSettings.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Settings/ClientSettings.cs @@ -32,7 +32,7 @@ internal sealed record ClientSpaceSettings(bool IndentWithTabs, int IndentSize) public int IndentSize { get; } = IndentSize >= 0 ? IndentSize : throw new ArgumentOutOfRangeException(nameof(IndentSize)); } -internal sealed record ClientAdvancedSettings(bool FormatOnType, bool AutoClosingTags, bool AutoInsertAttributeQuotes, bool ColorBackground, bool CodeBlockBraceOnNextLine, bool CommitElementsWithSpace, SnippetSetting SnippetSetting, LogLevel LogLevel, bool FormatOnPaste) +internal sealed record ClientAdvancedSettings(bool FormatOnType, bool AutoClosingTags, bool AutoInsertAttributeQuotes, bool ColorBackground, bool CodeBlockBraceOnNextLine, bool CommitElementsWithSpace, SnippetSetting SnippetSetting, LogLevel LogLevel) { - public static readonly ClientAdvancedSettings Default = new(FormatOnType: true, AutoClosingTags: true, AutoInsertAttributeQuotes: true, ColorBackground: false, CodeBlockBraceOnNextLine: false, CommitElementsWithSpace: true, SnippetSetting.All, LogLevel.Warning, FormatOnPaste: true); + public static readonly ClientAdvancedSettings Default = new(FormatOnType: true, AutoClosingTags: true, AutoInsertAttributeQuotes: true, ColorBackground: false, CodeBlockBraceOnNextLine: false, CommitElementsWithSpace: true, SnippetSetting.All, LogLevel.Warning); } diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostRangeFormattingEndpoint.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostRangeFormattingEndpoint.cs index a849a6d05c5..610679471c7 100644 --- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostRangeFormattingEndpoint.cs +++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostRangeFormattingEndpoint.cs @@ -70,14 +70,6 @@ public ImmutableArray GetRegistrations(VSInternalClientCapabilitie private async Task HandleRequestAsync(DocumentRangeFormattingParams request, TextDocument razorDocument, CancellationToken cancellationToken) { - if (request.Options.OtherOptions is not null && request.Options.OtherOptions.TryGetValue("fromPaste", out var fromPasteObj) && fromPasteObj is bool fromPaste) - { - if (fromPaste && !_clientSettingsManager.GetClientSettings().AdvancedSettings.FormatOnPaste) - { - return null; - } - } - _logger.LogDebug($"Getting Html formatting changes for {razorDocument.FilePath}"); var htmlResult = await TryGetHtmlFormattingEditsAsync(request, razorDocument, cancellationToken).ConfigureAwait(false); diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Options/OptionsStorage.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Options/OptionsStorage.cs index 5e28a880bae..e49ecb22145 100644 --- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Options/OptionsStorage.cs +++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Options/OptionsStorage.cs @@ -77,12 +77,6 @@ public LogLevel LogLevel set => SetInt(SettingsNames.LogLevel.LegacyName, (int)value); } - public bool FormatOnPaste - { - get => GetBool(SettingsNames.FormatOnPaste.LegacyName, defaultValue: true); - set => SetBool(SettingsNames.FormatOnPaste.LegacyName, value); - } - [ImportingConstructor] public OptionsStorage( SVsServiceProvider synchronousServiceProvider, @@ -113,7 +107,7 @@ public async Task OnChangedAsync(Action changed) private EventHandler? _changed; - public ClientAdvancedSettings GetAdvancedSettings() => new(FormatOnType, AutoClosingTags, AutoInsertAttributeQuotes, ColorBackground, CodeBlockBraceOnNextLine, CommitElementsWithSpace, Snippets, LogLevel, FormatOnPaste); + public ClientAdvancedSettings GetAdvancedSettings() => new(FormatOnType, AutoClosingTags, AutoInsertAttributeQuotes, ColorBackground, CodeBlockBraceOnNextLine, CommitElementsWithSpace, Snippets, LogLevel); public bool GetBool(string name, bool defaultValue) { diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Options/SettingsNames.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Options/SettingsNames.cs index 0aba1107461..75d10a365a9 100644 --- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Options/SettingsNames.cs +++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Options/SettingsNames.cs @@ -18,7 +18,6 @@ public record Setting(string LegacyName, string UnifiedName); public static readonly Setting CommitElementsWithSpace = new("CommitElementsWithSpace", UnifiedCollection + ".commitCharactersWithSpace"); public static readonly Setting Snippets = new("Snippets", UnifiedCollection + ".snippets"); public static readonly Setting LogLevel = new("LogLevel", UnifiedCollection + ".logLevel"); - public static readonly Setting FormatOnPaste = new("FormatOnPaste", UnifiedCollection + ".formatOnPaste"); public static readonly Setting[] AllSettings = [ @@ -30,6 +29,5 @@ public record Setting(string LegacyName, string UnifiedName); CommitElementsWithSpace, Snippets, LogLevel, - FormatOnPaste, ]; } diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/Options/AdvancedOptionPage.cs b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/Options/AdvancedOptionPage.cs index 264135fa679..f8a290761a7 100644 --- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/Options/AdvancedOptionPage.cs +++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/Options/AdvancedOptionPage.cs @@ -25,7 +25,6 @@ internal class AdvancedOptionPage : DialogPage private bool? _commitElementsWithSpace; private SnippetSetting? _snippets; private LogLevel? _logLevel; - private bool? _formatOnPaste; public AdvancedOptionPage() { @@ -92,15 +91,6 @@ public bool CodeBlockBraceOnNextLine set => _codeBlockBraceOnNextLine = value; } - [LocCategory(nameof(VSPackage.Formatting))] - [LocDescription(nameof(VSPackage.Setting_FormattingOnPasteDescription))] - [LocDisplayName(nameof(VSPackage.Setting_FormattingOnPasteDisplayName))] - public bool FormatOnPaste - { - get => _formatOnPaste ?? true; - set => _formatOnPaste = value; - } - [LocCategory(nameof(VSPackage.Completion))] [LocDescription(nameof(VSPackage.Setting_SnippetsDescription))] [LocDisplayName(nameof(VSPackage.Setting_SnippetsDisplayName))] diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/UnifiedSettings/razor.registration.json b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/UnifiedSettings/razor.registration.json index 3420468a7db..46dc8be958d 100644 --- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/UnifiedSettings/razor.registration.json +++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/UnifiedSettings/razor.registration.json @@ -17,192 +17,179 @@ "path": "Razor\\FormatOnType" } } - }, - "textEditor.razor.advanced.formatOnPaste": { - "type": "boolean", - "default": true, - "title": "@Setting_FormattingOnPasteDisplayName;{13b72f58-279e-49e0-a56d-296be02f0805}", - "description": "@Setting_FormattingOnPasteDescription;{13b72f58-279e-49e0-a56d-296be02f0805}", - "migration": { - "pass": { - "input": { - "store": "VsUserSettingsRegistry", - "path": "Razor\\FormatOnPaste" - } + } + }, + "textEditor.razor.advanced.autoClosingTags": { + "type": "boolean", + "default": true, + "title": "@Setting_AutoClosingTagsDisplayName;{13b72f58-279e-49e0-a56d-296be02f0805}", + "description": "@Setting_AutoClosingTagsDescription;{13b72f58-279e-49e0-a56d-296be02f0805}", + "migration": { + "pass": { + "input": { + "store": "VsUserSettingsRegistry", + "path": "Razor\\AutoClosingTags" } } - }, - "textEditor.razor.advanced.autoClosingTags": { - "type": "boolean", - "default": true, - "title": "@Setting_AutoClosingTagsDisplayName;{13b72f58-279e-49e0-a56d-296be02f0805}", - "description": "@Setting_AutoClosingTagsDescription;{13b72f58-279e-49e0-a56d-296be02f0805}", - "migration": { - "pass": { - "input": { - "store": "VsUserSettingsRegistry", - "path": "Razor\\AutoClosingTags" - } + } + }, + "textEditor.razor.advanced.autoInsertAttributeQuotes": { + "type": "boolean", + "default": true, + "title": "@Setting_AutoInsertAttributeQuotesDisplayName;{13b72f58-279e-49e0-a56d-296be02f0805}", + "description": "@Setting_AutoInsertAttributeQuotesDescription;{13b72f58-279e-49e0-a56d-296be02f0805}", + "migration": { + "pass": { + "input": { + "store": "VsUserSettingsRegistry", + "path": "Razor\\AutoInsertAttributeQuotes" } } - }, - "textEditor.razor.advanced.autoInsertAttributeQuotes": { - "type": "boolean", - "default": true, - "title": "@Setting_AutoInsertAttributeQuotesDisplayName;{13b72f58-279e-49e0-a56d-296be02f0805}", - "description": "@Setting_AutoInsertAttributeQuotesDescription;{13b72f58-279e-49e0-a56d-296be02f0805}", - "migration": { - "pass": { - "input": { - "store": "VsUserSettingsRegistry", - "path": "Razor\\AutoInsertAttributeQuotes" - } + } + }, + "textEditor.razor.advanced.colorBackground": { + "type": "boolean", + "default": false, + "title": "@Setting_ColorBackgroundDisplayName;{13b72f58-279e-49e0-a56d-296be02f0805}", + "description": "@Setting_ColorBackgroundDescription;{13b72f58-279e-49e0-a56d-296be02f0805}", + "migration": { + "pass": { + "input": { + "store": "VsUserSettingsRegistry", + "path": "Razor\\ColorBackground" } } - }, - "textEditor.razor.advanced.colorBackground": { - "type": "boolean", - "default": false, - "title": "@Setting_ColorBackgroundDisplayName;{13b72f58-279e-49e0-a56d-296be02f0805}", - "description": "@Setting_ColorBackgroundDescription;{13b72f58-279e-49e0-a56d-296be02f0805}", - "migration": { - "pass": { - "input": { - "store": "VsUserSettingsRegistry", - "path": "Razor\\ColorBackground" - } + } + }, + "textEditor.razor.advanced.codeBlockBraceOnNextLine": { + "type": "boolean", + "default": false, + "title": "@Setting_CodeBlockBraceOnNextLineDisplayName;{13b72f58-279e-49e0-a56d-296be02f0805}", + "description": "@Setting_CodeBlockBraceOnNextLineDescription;{13b72f58-279e-49e0-a56d-296be02f0805}", + "migration": { + "pass": { + "input": { + "store": "VsUserSettingsRegistry", + "path": "Razor\\CodeBlockBraceOnNextLined" } } - }, - "textEditor.razor.advanced.codeBlockBraceOnNextLine": { - "type": "boolean", - "default": false, - "title": "@Setting_CodeBlockBraceOnNextLineDisplayName;{13b72f58-279e-49e0-a56d-296be02f0805}", - "description": "@Setting_CodeBlockBraceOnNextLineDescription;{13b72f58-279e-49e0-a56d-296be02f0805}", - "migration": { - "pass": { - "input": { - "store": "VsUserSettingsRegistry", - "path": "Razor\\CodeBlockBraceOnNextLined" - } + } + }, + "textEditor.razor.advanced.commitElementsWithSpace": { + "type": "boolean", + "default": true, + "title": "@Setting_CommitElementsWithSpaceDisplayName;{13b72f58-279e-49e0-a56d-296be02f0805}", + "description": "@Setting_CommitElementsWithSpaceDescription;{13b72f58-279e-49e0-a56d-296be02f0805}", + "migration": { + "pass": { + "input": { + "store": "VsUserSettingsRegistry", + "path": "Razor\\CommitElementsWithSpace" } } - }, - "textEditor.razor.advanced.commitElementsWithSpace": { - "type": "boolean", - "default": true, - "title": "@Setting_CommitElementsWithSpaceDisplayName;{13b72f58-279e-49e0-a56d-296be02f0805}", - "description": "@Setting_CommitElementsWithSpaceDescription;{13b72f58-279e-49e0-a56d-296be02f0805}", - "migration": { - "pass": { - "input": { - "store": "VsUserSettingsRegistry", - "path": "Razor\\CommitElementsWithSpace" + } + }, + "textEditor.razor.advanced.snippets": { + "type": "string", + "default": "all", + "enum": [ + "all", + "custom", + "none" + ], + "enumItemLabels": [ + "@Setting_SnippetsAll;{13b72f58-279e-49e0-a56d-296be02f0805}", + "@Setting_SnippetsCustom;{13b72f58-279e-49e0-a56d-296be02f0805}", + "@Setting_SnippetsNone;{13b72f58-279e-49e0-a56d-296be02f0805}" + ], + "title": "@Setting_SnippetsDisplayName;{13b72f58-279e-49e0-a56d-296be02f0805}", + "description": "@Setting_SnippetsDescription;{13b72f58-279e-49e0-a56d-296be02f0805}", + "migration": { + "enumIntegerToString": { + "input": { + "store": "VsUserSettingsRegistry", + "path": "Razor\\Snippets" + }, + "map": [ + { + "result": "all", + "match": 0 + }, + { + "result": "custom", + "match": 1 + }, + { + "result": "none", + "match": 2 } - } + ] } - }, - "textEditor.razor.advanced.snippets": { - "type": "string", - "default": "all", - "enum": [ - "all", - "custom", - "none" - ], - "enumItemLabels": [ - "@Setting_SnippetsAll;{13b72f58-279e-49e0-a56d-296be02f0805}", - "@Setting_SnippetsCustom;{13b72f58-279e-49e0-a56d-296be02f0805}", - "@Setting_SnippetsNone;{13b72f58-279e-49e0-a56d-296be02f0805}" - ], - "title": "@Setting_SnippetsDisplayName;{13b72f58-279e-49e0-a56d-296be02f0805}", - "description": "@Setting_SnippetsDescription;{13b72f58-279e-49e0-a56d-296be02f0805}", - "migration": { - "enumIntegerToString": { - "input": { - "store": "VsUserSettingsRegistry", - "path": "Razor\\Snippets" + } + }, + "textEditor.razor.advanced.logLevel": { + "type": "string", + "default": "warning", + "enum": [ + "trace", + "debug", + "information", + "warning", + "error", + "critical", + "none" + ], + "enumItemLabels": [ + "@Setting_LogLevelTrace;{13b72f58-279e-49e0-a56d-296be02f0805}", + "@Setting_LogLevelDebug;{13b72f58-279e-49e0-a56d-296be02f0805}", + "@Setting_LogLevelInformation;{13b72f58-279e-49e0-a56d-296be02f0805}", + "@Setting_LogLevelWarning;{13b72f58-279e-49e0-a56d-296be02f0805}", + "@Setting_LogLevelError;{13b72f58-279e-49e0-a56d-296be02f0805}", + "@Setting_LogLevelCritical;{13b72f58-279e-49e0-a56d-296be02f0805}", + "@Setting_LogLevelNone;{13b72f58-279e-49e0-a56d-296be02f0805}" + ], + "title": "@Setting_LogLevelDisplayName;{13b72f58-279e-49e0-a56d-296be02f0805}", + "description": "@Setting_LogLevelDescription;{13b72f58-279e-49e0-a56d-296be02f0805}", + "migration": { + "enumIntegerToString": { + "input": { + "store": "VsUserSettingsRegistry", + "path": "Razor\\LogLevel" + }, + "map": [ + { + "result": "trace", + "match": 0 }, - "map": [ - { - "result": "all", - "match": 0 - }, - { - "result": "custom", - "match": 1 - }, - { - "result": "none", - "match": 2 - } - ] - } - } - }, - "textEditor.razor.advanced.logLevel": { - "type": "string", - "default": "warning", - "enum": [ - "trace", - "debug", - "information", - "warning", - "error", - "critical", - "none" - ], - "enumItemLabels": [ - "@Setting_LogLevelTrace;{13b72f58-279e-49e0-a56d-296be02f0805}", - "@Setting_LogLevelDebug;{13b72f58-279e-49e0-a56d-296be02f0805}", - "@Setting_LogLevelInformation;{13b72f58-279e-49e0-a56d-296be02f0805}", - "@Setting_LogLevelWarning;{13b72f58-279e-49e0-a56d-296be02f0805}", - "@Setting_LogLevelError;{13b72f58-279e-49e0-a56d-296be02f0805}", - "@Setting_LogLevelCritical;{13b72f58-279e-49e0-a56d-296be02f0805}", - "@Setting_LogLevelNone;{13b72f58-279e-49e0-a56d-296be02f0805}" - ], - "title": "@Setting_LogLevelDisplayName;{13b72f58-279e-49e0-a56d-296be02f0805}", - "description": "@Setting_LogLevelDescription;{13b72f58-279e-49e0-a56d-296be02f0805}", - "migration": { - "enumIntegerToString": { - "input": { - "store": "VsUserSettingsRegistry", - "path": "Razor\\LogLevel" + { + "result": "debug", + "match": 1 }, - "map": [ - { - "result": "trace", - "match": 0 - }, - { - "result": "debug", - "match": 1 - }, - { - "result": "information", - "match": 2 - }, - { - "result": "warning", - "match": 3 - }, - { - "result": "error", - "match": 4 - }, - { - "result": "critical", - "match": 5 - }, - { - "result": "none", - "match": 6 - } - ] - } + { + "result": "information", + "match": 2 + }, + { + "result": "warning", + "match": 3 + }, + { + "result": "error", + "match": 4 + }, + { + "result": "critical", + "match": 5 + }, + { + "result": "none", + "match": 6 + } + ] } } - }, + } + }, "categories": { "textEditor.razor": { "title": "@110;{13b72f58-279e-49e0-a56d-296be02f0805}" // Razor (ASP.NET Core) diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/VSPackage.resx b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/VSPackage.resx index 9942e572b2f..7a9e0223550 100644 --- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/VSPackage.resx +++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/VSPackage.resx @@ -180,12 +180,6 @@ Commit elements with space - - Format on paste - - - If true, formatting will be enabled when pasting content - If true, formatting will be enabled while typing diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.cs.xlf b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.cs.xlf index b349bd852b9..f761260c51b 100644 --- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.cs.xlf +++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.cs.xlf @@ -92,16 +92,6 @@ Potvrzovat elementy mezerníkem - - If true, formatting will be enabled when pasting content - Pokud je true, při vkládání obsahu se povolí formátování. - - - - Format on paste - Formátovat při vložení - - If true, formatting will be enabled while typing Pokud je hodnota true, při psaní se povolí formátování. diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.de.xlf b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.de.xlf index 9b8101e961b..c3df4f2b10f 100644 --- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.de.xlf +++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.de.xlf @@ -92,16 +92,6 @@ Elemente durch Drücken der LEERTASTE committen - - If true, formatting will be enabled when pasting content - „True“ gibt an, dass die Formatierung beim Einfügen von Inhalten aktiviert wird. - - - - Format on paste - Beim Einfügen formatieren - - If true, formatting will be enabled while typing Bei "true" wird die Formatierung während der Eingabe aktiviert. diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.es.xlf b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.es.xlf index 6feb41cb5b9..61ad53589dd 100644 --- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.es.xlf +++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.es.xlf @@ -92,16 +92,6 @@ Confirmar elementos con espacio - - If true, formatting will be enabled when pasting content - Si es true, se habilitará la aplicación de formato al pegar contenido - - - - Format on paste - Dar formato al pegar - - If true, formatting will be enabled while typing Si es true, el formato se habilitará al escribir diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.fr.xlf b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.fr.xlf index 69271cdb768..080df931e38 100644 --- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.fr.xlf +++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.fr.xlf @@ -92,16 +92,7 @@ Valider des éléments avec de l’espace - - If true, formatting will be enabled when pasting content - Si la valeur est true, la mise en forme sera activée lors du collage du contenu - - - - Format on paste - Mettre en forme lors du collage - - + If true, formatting will be enabled while typing Si la valeur est true, la mise en forme est activée lors de la saisie diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.it.xlf b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.it.xlf index 83e5a587e77..ff83731d724 100644 --- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.it.xlf +++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.it.xlf @@ -92,16 +92,6 @@ Eseguire il commit degli elementi con lo spazio - - If true, formatting will be enabled when pasting content - Se true, la formattazione verrà abilitata quando viene incollato il contenuto - - - - Format on paste - Formatta quando si incolla - - If true, formatting will be enabled while typing Se true, la formattazione verrà abilitata durante la digitazione diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.ja.xlf b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.ja.xlf index 16c78d177d0..4966f450d6e 100644 --- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.ja.xlf +++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.ja.xlf @@ -92,6 +92,7 @@ スペースを含む要素のコミット +<<<<<<< HEAD If true, formatting will be enabled when pasting content true の場合、コンテンツを貼り付けたときに書式設定が有効になります @@ -102,6 +103,8 @@ 貼り付け時に書式設定する +======= +>>>>>>> parent of 019b7c81e (Add option for format on paste (#11039)) If true, formatting will be enabled while typing true の場合、入力中に書式設定が有効になります diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.ko.xlf b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.ko.xlf index 25a1f9a374e..c844ba635ac 100644 --- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.ko.xlf +++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.ko.xlf @@ -92,16 +92,6 @@ 공백을 사용하여 요소 커밋 - - If true, formatting will be enabled when pasting content - If true, formatting will be enabled when pasting content - - - - Format on paste - Format on paste - - If true, formatting will be enabled while typing true이면 입력하는 동안 서식을 사용할 수 있습니다. diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.pl.xlf b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.pl.xlf index 15e1b0445e6..dc3dfbd58a3 100644 --- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.pl.xlf +++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.pl.xlf @@ -92,16 +92,6 @@ Zatwierdź elementy za pomocą klawisza Spacja - - If true, formatting will be enabled when pasting content - If true, formatting will be enabled when pasting content - - - - Format on paste - Format on paste - - If true, formatting will be enabled while typing Jeśli ma wartość „prawda”, formatowanie będzie włączone podczas pisania diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.pt-BR.xlf b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.pt-BR.xlf index c13c6321f22..d810afc1c52 100644 --- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.pt-BR.xlf +++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.pt-BR.xlf @@ -92,6 +92,7 @@ Confirmar elementos com espaço +<<<<<<< HEAD If true, formatting will be enabled when pasting content Se for true, a formatação será habilitada ao colar conteúdo @@ -102,6 +103,8 @@ Formatar ao colar +======= +>>>>>>> parent of 019b7c81e (Add option for format on paste (#11039)) If true, formatting will be enabled while typing Se verdadeiro, a formatação será habilitada durante a digitação diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.ru.xlf b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.ru.xlf index 53ff562ecb8..da4769d5d20 100644 --- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.ru.xlf +++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.ru.xlf @@ -92,6 +92,7 @@ Фиксация элементов клавишей ПРОБЕЛ +<<<<<<< HEAD If true, formatting will be enabled when pasting content Если ИСТИНА, форматирование будет включено при вставке контента. @@ -102,6 +103,8 @@ Форматировать при вставке +======= +>>>>>>> parent of 019b7c81e (Add option for format on paste (#11039)) If true, formatting will be enabled while typing Если задано значение true, при вводе текста будет включено форматирование diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.tr.xlf b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.tr.xlf index 3026631fe92..2d871d26639 100644 --- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.tr.xlf +++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.tr.xlf @@ -92,16 +92,6 @@ Öğeleri boşluk çubuğuyla işle - - If true, formatting will be enabled when pasting content - If true, formatting will be enabled when pasting content - - - - Format on paste - Format on paste - - If true, formatting will be enabled while typing True ise, yazma sırasında biçimlendirme etkinleştirilir diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.zh-Hans.xlf b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.zh-Hans.xlf index 0d8454bc47f..1a428d7836c 100644 --- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.zh-Hans.xlf +++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.zh-Hans.xlf @@ -92,16 +92,6 @@ 使用空格键提交元素 - - If true, formatting will be enabled when pasting content - If true, formatting will be enabled when pasting content - - - - Format on paste - Format on paste - - If true, formatting will be enabled while typing 如果为 true,则在键入时将启用格式设置 diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.zh-Hant.xlf b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.zh-Hant.xlf index 238c43570cd..1779abb2bac 100644 --- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.zh-Hant.xlf +++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/xlf/VSPackage.zh-Hant.xlf @@ -92,16 +92,6 @@ 透過空格鍵認可元素 - - If true, formatting will be enabled when pasting content - If true, formatting will be enabled when pasting content - - - - Format on paste - Format on paste - - If true, formatting will be enabled while typing 如果為 True,則會在輸入時啟用格式化 diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CodeActionEndToEndTest.NetFx.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CodeActionEndToEndTest.NetFx.cs index 523591dd0ee..4b9e5380267 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CodeActionEndToEndTest.NetFx.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/CodeActionEndToEndTest.NetFx.cs @@ -802,12 +802,13 @@ public async Task Handle_GenerateMethod_VaryIndentSize(bool insertSpaces, int ta """; var razorLSPOptions = new RazorLSPOptions( - FormattingFlags.All, + EnableFormatting: true, AutoClosingTags: true, insertSpaces, tabSize, AutoShowCompletion: true, AutoListParams: true, + FormatOnType: true, AutoInsertAttributeQuotes: true, ColorBackground: false, CodeBlockBraceOnNextLine: false, diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/DefaultRazorConfigurationServiceTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/DefaultRazorConfigurationServiceTest.cs index 9be85770208..29048394810 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/DefaultRazorConfigurationServiceTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/DefaultRazorConfigurationServiceTest.cs @@ -22,7 +22,7 @@ public async Task GetLatestOptionsAsync_ReturnsExpectedOptions() { // Arrange var expectedOptions = new RazorLSPOptions( - FormattingFlags.Disabled, AutoClosingTags: false, InsertSpaces: true, TabSize: 4, AutoShowCompletion: true, AutoListParams: true, AutoInsertAttributeQuotes: true, ColorBackground: false, CodeBlockBraceOnNextLine: true, CommitElementsWithSpace: false); + EnableFormatting: false, AutoClosingTags: false, InsertSpaces: true, TabSize: 4, AutoShowCompletion: true, AutoListParams: true, FormatOnType: true, AutoInsertAttributeQuotes: true, ColorBackground: false, CodeBlockBraceOnNextLine: true, CommitElementsWithSpace: false); var razorJsonString = """ @@ -94,7 +94,7 @@ public void BuildOptions_VSCodeOptionsOnly_ReturnsExpected() { // Arrange - purposely choosing options opposite of default var expectedOptions = new RazorLSPOptions( - FormattingFlags.Disabled, AutoClosingTags: false, InsertSpaces: true, TabSize: 4, AutoShowCompletion: true, AutoListParams: true, AutoInsertAttributeQuotes: true, ColorBackground: false, CodeBlockBraceOnNextLine: true, CommitElementsWithSpace: false); + EnableFormatting: false, AutoClosingTags: false, InsertSpaces: true, TabSize: 4, AutoShowCompletion: true, AutoListParams: true, FormatOnType: true, AutoInsertAttributeQuotes: true, ColorBackground: false, CodeBlockBraceOnNextLine: true, CommitElementsWithSpace: false); var razorJsonString = """ { "format": { @@ -131,7 +131,7 @@ public void BuildOptions_VSOptionsOnly_ReturnsExpected() { // Arrange - purposely choosing options opposite of default var expectedOptions = new RazorLSPOptions( - FormattingFlags.Enabled, AutoClosingTags: false, InsertSpaces: false, TabSize: 8, AutoShowCompletion: true, AutoListParams: true, AutoInsertAttributeQuotes: false, ColorBackground: false, CodeBlockBraceOnNextLine: false, CommitElementsWithSpace: false); + EnableFormatting: true, AutoClosingTags: false, InsertSpaces: false, TabSize: 8, AutoShowCompletion: true, AutoListParams: true, FormatOnType: false, AutoInsertAttributeQuotes: false, ColorBackground: false, CodeBlockBraceOnNextLine: false, CommitElementsWithSpace: false); var razorJsonString = """ { } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentRangeFormattingEndpointTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentRangeFormattingEndpointTest.cs index 550db0cc4a2..bd667e180a8 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentRangeFormattingEndpointTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentRangeFormattingEndpointTest.cs @@ -79,7 +79,7 @@ public async Task Handle_UnsupportedCodeDocument_ReturnsNull() var endpoint = new DocumentRangeFormattingEndpoint(formattingService, htmlFormatter, optionsMonitor); var @params = new DocumentRangeFormattingParams() { - TextDocument = new TextDocumentIdentifier { Uri = uri, }, + TextDocument = new TextDocumentIdentifier { Uri = uri, } }; var requestContext = CreateRazorRequestContext(documentContext); @@ -107,32 +107,4 @@ public async Task Handle_FormattingDisabled_ReturnsNull() // Assert Assert.Null(result); } - - [Fact] - public async Task Handle_FormattingOnPasteDisabled_ReturnsNull() - { - // Arrange - var formattingService = new DummyRazorFormattingService(); - var optionsMonitor = GetOptionsMonitor(formatOnPaste: false); - var htmlFormatter = new TestHtmlFormatter(); - var endpoint = new DocumentRangeFormattingEndpoint(formattingService, htmlFormatter, optionsMonitor); - var @params = new DocumentRangeFormattingParams() - { - Options = new() - { - OtherOptions = new() - { - { "fromPaste", true } - } - } - }; - - var requestContext = CreateRazorRequestContext(documentContext: null); - - // Act - var result = await endpoint.HandleRequestAsync(@params, requestContext, DisposalToken); - - // Assert - Assert.Null(result); - } } diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/RazorFormattingTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/RazorFormattingTest.cs index baa075aaa1f..aa1400fbe62 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/RazorFormattingTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/RazorFormattingTest.cs @@ -814,7 +814,7 @@ private void IncrementCount() } """, triggerCharacter: '}', - razorLSPOptions: RazorLSPOptions.Default); + razorLSPOptions: RazorLSPOptions.Default with { FormatOnType = true }); } [Fact] diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorLSPOptionsMonitorTest.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorLSPOptionsMonitorTest.cs index 973d319eb9e..923c290ca46 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorLSPOptionsMonitorTest.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/RazorLSPOptionsMonitorTest.cs @@ -23,7 +23,7 @@ public RazorLSPOptionsMonitorTest(ITestOutputHelper testOutput) public async Task UpdateAsync_Invokes_OnChangeRegistration() { // Arrange - var expectedOptions = new RazorLSPOptions(FormattingFlags.Disabled, AutoClosingTags: true, InsertSpaces: true, TabSize: 4, AutoShowCompletion: true, AutoListParams: true, AutoInsertAttributeQuotes: true, ColorBackground: false, CodeBlockBraceOnNextLine: false, CommitElementsWithSpace: true); + var expectedOptions = new RazorLSPOptions(EnableFormatting: false, AutoClosingTags: true, InsertSpaces: true, TabSize: 4, AutoShowCompletion: true, AutoListParams: true, FormatOnType: true, AutoInsertAttributeQuotes: true, ColorBackground: false, CodeBlockBraceOnNextLine: false, CommitElementsWithSpace: true); var configService = Mock.Of( f => f.GetLatestOptionsAsync(DisposalToken) == Task.FromResult(expectedOptions), MockBehavior.Strict); @@ -45,7 +45,7 @@ public async Task UpdateAsync_Invokes_OnChangeRegistration() public async Task UpdateAsync_DoesNotInvoke_OnChangeRegistration_AfterDispose() { // Arrange - var expectedOptions = new RazorLSPOptions(FormattingFlags.Disabled, AutoClosingTags: true, InsertSpaces: true, TabSize: 4, AutoShowCompletion: true, AutoListParams: true, AutoInsertAttributeQuotes: true, ColorBackground: false, CodeBlockBraceOnNextLine: false, CommitElementsWithSpace: true); + var expectedOptions = new RazorLSPOptions(EnableFormatting: false, AutoClosingTags: true, InsertSpaces: true, TabSize: 4, AutoShowCompletion: true, AutoListParams: true, FormatOnType: true, AutoInsertAttributeQuotes: true, ColorBackground: false, CodeBlockBraceOnNextLine: false, CommitElementsWithSpace: true); var configService = Mock.Of( f => f.GetLatestOptionsAsync(DisposalToken) == Task.FromResult(expectedOptions), MockBehavior.Strict); @@ -91,7 +91,7 @@ public async Task UpdateAsync_ConfigReturnsNull_DoesNotInvoke_OnChangeRegistrati public void InitializedOptionsAreCurrent() { // Arrange - var expectedOptions = new RazorLSPOptions(FormattingFlags.Disabled, AutoClosingTags: true, InsertSpaces: true, TabSize: 4, AutoShowCompletion: true, AutoListParams: true, AutoInsertAttributeQuotes: true, ColorBackground: false, CodeBlockBraceOnNextLine: false, CommitElementsWithSpace: true); + var expectedOptions = new RazorLSPOptions(EnableFormatting: false, AutoClosingTags: true, InsertSpaces: true, TabSize: 4, AutoShowCompletion: true, AutoListParams: true, FormatOnType: true, AutoInsertAttributeQuotes: true, ColorBackground: false, CodeBlockBraceOnNextLine: false, CommitElementsWithSpace: true); var configService = Mock.Of( f => f.GetLatestOptionsAsync(DisposalToken) == Task.FromResult(expectedOptions), MockBehavior.Strict); diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/LanguageServerTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/LanguageServerTestBase.cs index 9b9c878a08f..7bd6d140ce2 100644 --- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/LanguageServerTestBase.cs +++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Tooling/LanguageServer/LanguageServerTestBase.cs @@ -127,56 +127,15 @@ private protected static DocumentContext CreateDocumentContext(Uri uri, IDocumen return new DocumentContext(uri, snapshot, projectContext: null); } - private protected static RazorLSPOptionsMonitor GetOptionsMonitor( - bool enableFormatting = true, - bool autoShowCompletion = true, - bool autoListParams = true, - bool formatOnType = true, - bool autoInsertAttributeQuotes = true, - bool colorBackground = false, - bool codeBlockBraceOnNextLine = false, - bool commitElementsWithSpace = true, - bool formatOnPaste = true) + private protected static RazorLSPOptionsMonitor GetOptionsMonitor(bool enableFormatting = true, bool autoShowCompletion = true, bool autoListParams = true, bool formatOnType = true, bool autoInsertAttributeQuotes = true, bool colorBackground = false, bool codeBlockBraceOnNextLine = false, bool commitElementsWithSpace = true) { var configService = StrictMock.Of(); - var options = new RazorLSPOptions( - GetFormattingFlags(enableFormatting, formatOnType, formatOnPaste), - true, - InsertSpaces: true, - TabSize: 4, - autoShowCompletion, - autoListParams, - autoInsertAttributeQuotes, - colorBackground, - codeBlockBraceOnNextLine, - commitElementsWithSpace); + var options = new RazorLSPOptions(enableFormatting, true, InsertSpaces: true, TabSize: 4, autoShowCompletion, autoListParams, formatOnType, autoInsertAttributeQuotes, colorBackground, codeBlockBraceOnNextLine, commitElementsWithSpace); var optionsMonitor = new RazorLSPOptionsMonitor(configService, options); return optionsMonitor; } - private static FormattingFlags GetFormattingFlags(bool enableFormatting, bool formatOnType, bool formatOnPaste) - { - var flags = FormattingFlags.Disabled; - - if (enableFormatting) - { - flags |= FormattingFlags.Enabled; - } - - if (formatOnType) - { - flags |= FormattingFlags.OnType; - } - - if (formatOnPaste) - { - flags |= FormattingFlags.OnPaste; - } - - return flags; - } - private class ThrowingRazorSpanMappingService : IRazorSpanMappingService { public Task> MapSpansAsync(Document document, IEnumerable spans, CancellationToken cancellationToken) diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Settings/ClientSettingsManagerTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Settings/ClientSettingsManagerTest.cs index 0edfde8f751..498fb92da12 100644 --- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Settings/ClientSettingsManagerTest.cs +++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Settings/ClientSettingsManagerTest.cs @@ -82,7 +82,7 @@ public void Update_TriggersChangedIfAdvancedSettingsAreDifferent() var manager = new ClientSettingsManager(_clientSettingsChangeTriggers); var called = false; manager.ClientSettingsChanged += (caller, args) => called = true; - var settings = new ClientAdvancedSettings(FormatOnType: false, AutoClosingTags: true, AutoInsertAttributeQuotes: true, ColorBackground: true, CodeBlockBraceOnNextLine: false, CommitElementsWithSpace: false, SnippetSetting: default, LogLevel: default, FormatOnPaste: false); + var settings = new ClientAdvancedSettings(FormatOnType: false, AutoClosingTags: true, AutoInsertAttributeQuotes: true, ColorBackground: true, CodeBlockBraceOnNextLine: false, CommitElementsWithSpace: false, SnippetSetting: default, LogLevel: default); // Act manager.Update(settings);