@@ -202,13 +202,8 @@ class PSDocumentFormattingEditProvider implements
202
202
document : TextDocument ,
203
203
options : FormattingOptions ,
204
204
token : CancellationToken ) : TextEdit [ ] | Thenable < TextEdit [ ] > {
205
- return this . languageClient . sendRequest (
206
- DocumentFormattingRequest . type ,
207
- {
208
- textDocument : TextDocumentIdentifier . create ( document . uri . toString ( ) ) ,
209
- options : this . getEditorSettings ( )
210
- } ) ;
211
- }
205
+ return this . provideDocumentRangeFormattingEdits ( document , null , options , token ) ;
206
+ }
212
207
213
208
provideDocumentRangeFormattingEdits (
214
209
document : TextDocument ,
@@ -227,9 +222,12 @@ class PSDocumentFormattingEditProvider implements
227
222
return this . emptyPromise ;
228
223
}
229
224
230
- let requestParams : DocumentRangeFormattingParams = {
231
- textDocument : TextDocumentIdentifier . create ( document . uri . toString ( ) ) ,
232
- range : {
225
+
226
+ // somehow range object gets serialized to an array of Position objects,
227
+ // so we need to use the object literal syntax to initialize it.
228
+ let rangeParam = null ;
229
+ if ( range != null ) {
230
+ rangeParam = {
233
231
start : {
234
232
line : range . start . line ,
235
233
character : range . start . character
@@ -238,7 +236,12 @@ class PSDocumentFormattingEditProvider implements
238
236
line : range . end . line ,
239
237
character : range . end . character
240
238
}
241
- } ,
239
+ } ;
240
+ } ;
241
+
242
+ let requestParams : DocumentRangeFormattingParams = {
243
+ textDocument : TextDocumentIdentifier . create ( document . uri . toString ( ) ) ,
244
+ range : rangeParam ,
242
245
options : this . getEditorSettings ( )
243
246
} ;
244
247
0 commit comments