8
8
using System . Threading ;
9
9
using System . Threading . Tasks ;
10
10
using Microsoft . CodeAnalysis ;
11
+ using Microsoft . CodeAnalysis . ExternalAccess . Razor ;
11
12
using Microsoft . CodeAnalysis . ExternalAccess . Razor . Cohost ;
12
13
using Microsoft . CodeAnalysis . ExternalAccess . Razor . Features ;
13
14
using Microsoft . CodeAnalysis . Razor . Cohost ;
@@ -60,7 +61,13 @@ public ImmutableArray<Registration> GetRegistrations(VSInternalClientCapabilitie
60
61
protected override RazorTextDocumentIdentifier ? GetRazorTextDocumentIdentifier ( DocumentFormattingParams request )
61
62
=> request . TextDocument . ToRazorTextDocumentIdentifier ( ) ;
62
63
63
- protected override async Task < TextEdit [ ] ? > HandleRequestAsync ( DocumentFormattingParams request , TextDocument razorDocument , CancellationToken cancellationToken )
64
+ protected override Task < TextEdit [ ] ? > HandleRequestAsync ( DocumentFormattingParams request , TextDocument razorDocument , CancellationToken cancellationToken )
65
+ {
66
+ var csharpSyntaxFormattingOptions = RazorCSharpFormattingInteractionService . GetRazorCSharpSyntaxFormattingOptions ( razorDocument . Project . Solution . Services ) ;
67
+ return HandleRequestAsync ( request , razorDocument , csharpSyntaxFormattingOptions , cancellationToken ) ;
68
+ }
69
+
70
+ private async Task < TextEdit [ ] ? > HandleRequestAsync ( DocumentFormattingParams request , TextDocument razorDocument , RazorCSharpSyntaxFormattingOptions csharpSyntaxFormattingOptions , CancellationToken cancellationToken )
64
71
{
65
72
_logger . LogDebug ( $ "Getting Html formatting changes for { razorDocument . FilePath } ") ;
66
73
var htmlResult = await TryGetHtmlFormattingEditsAsync ( request , razorDocument , cancellationToken ) . ConfigureAwait ( false ) ;
@@ -75,7 +82,10 @@ public ImmutableArray<Registration> GetRegistrations(VSInternalClientCapabilitie
75
82
var sourceText = await razorDocument . GetTextAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
76
83
var htmlChanges = htmlEdits . SelectAsArray ( sourceText . GetTextChange ) ;
77
84
78
- var options = RazorFormattingOptions . From ( request . Options , _clientSettingsManager . GetClientSettings ( ) . AdvancedSettings . CodeBlockBraceOnNextLine ) ;
85
+ var options = RazorFormattingOptions . From (
86
+ request . Options ,
87
+ _clientSettingsManager . GetClientSettings ( ) . AdvancedSettings . CodeBlockBraceOnNextLine ,
88
+ csharpSyntaxFormattingOptions ) ;
79
89
80
90
_logger . LogDebug ( $ "Calling OOP with the { htmlChanges . Length } html edits, so it can fill in the rest") ;
81
91
var remoteResult = await _remoteServiceInvoker . TryInvokeAsync < IRemoteFormattingService , ImmutableArray < TextChange > > (
@@ -114,8 +124,7 @@ public ImmutableArray<Registration> GetRegistrations(VSInternalClientCapabilitie
114
124
115
125
internal readonly struct TestAccessor ( CohostDocumentFormattingEndpoint instance )
116
126
{
117
- public Task < TextEdit [ ] ? > HandleRequestAsync ( DocumentFormattingParams request , TextDocument razorDocument , CancellationToken cancellationToken )
118
- => instance . HandleRequestAsync ( request , razorDocument , cancellationToken ) ;
127
+ public Task < TextEdit [ ] ? > HandleRequestAsync ( DocumentFormattingParams request , TextDocument razorDocument , RazorCSharpSyntaxFormattingOptions csharpSyntaxFormattingOptions , CancellationToken cancellationToken )
128
+ => instance . HandleRequestAsync ( request , razorDocument , csharpSyntaxFormattingOptions , cancellationToken ) ;
119
129
}
120
130
}
121
-
0 commit comments