diff --git a/src/Tools/ExternalAccess/Razor/RazorCSharpFormattingInteractionService.cs b/src/Tools/ExternalAccess/Razor/RazorCSharpFormattingInteractionService.cs index 17cbcfedf4f45..0e41ead45f3ad 100644 --- a/src/Tools/ExternalAccess/Razor/RazorCSharpFormattingInteractionService.cs +++ b/src/Tools/ExternalAccess/Razor/RazorCSharpFormattingInteractionService.cs @@ -15,7 +15,15 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.Razor { - internal readonly record struct RazorFormattingOptions(bool UseTabs, int TabSize, int IndentationSize); + internal readonly record struct RazorFormattingOptions( + bool UseTabs, + int TabSize, + int IndentationSize, + FormattingOptions.IndentStyle IndentStyle, + bool FormatOnReturn, + bool FormatOnTyping, + bool FormatOnSemicolon, + bool FormatOnCloseBrace); /// /// Enables Razor to utilize Roslyn's C# formatting service. @@ -64,12 +72,17 @@ public static async Task> GetFormattingChangesAsync( var formattingService = document.GetRequiredLanguageService(); var formattingOptions = await SyntaxFormattingOptions.FromDocumentAsync(document, cancellationToken).ConfigureAwait(false); - // TODO: get auto-formatting options from Razor - var globalOptions = document.Project.Solution.Workspace.Services.GetRequiredService(); - var indentationOptions = new IndentationOptions( - formattingOptions.With(options.UseTabs, options.TabSize, options.IndentationSize), - globalOptions.GlobalOptions.GetAutoFormattingOptions(document.Project.Language)); + formattingOptions.With( + useTabs: options.UseTabs, + tabSize: options.TabSize, + indentationSize: options.IndentationSize), + new AutoFormattingOptions( + IndentStyle: options.IndentStyle, + FormatOnReturn: options.FormatOnReturn, + FormatOnTyping: options.FormatOnTyping, + FormatOnSemicolon: options.FormatOnSemicolon, + FormatOnCloseBrace: options.FormatOnCloseBrace)); return await formattingService.GetFormattingChangesAsync(document, typedChar, position, indentationOptions, cancellationToken).ConfigureAwait(false); }