@@ -202,13 +202,8 @@ class PSDocumentFormattingEditProvider implements
202202 document : TextDocument ,
203203 options : FormattingOptions ,
204204 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+ }
212207
213208 provideDocumentRangeFormattingEdits (
214209 document : TextDocument ,
@@ -227,9 +222,12 @@ class PSDocumentFormattingEditProvider implements
227222 return this . emptyPromise ;
228223 }
229224
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 = {
233231 start : {
234232 line : range . start . line ,
235233 character : range . start . character
@@ -238,7 +236,12 @@ class PSDocumentFormattingEditProvider implements
238236 line : range . end . line ,
239237 character : range . end . character
240238 }
241- } ,
239+ } ;
240+ } ;
241+
242+ let requestParams : DocumentRangeFormattingParams = {
243+ textDocument : TextDocumentIdentifier . create ( document . uri . toString ( ) ) ,
244+ range : rangeParam ,
242245 options : this . getEditorSettings ( )
243246 } ;
244247
0 commit comments