@@ -90,6 +90,10 @@ function toRange(scriptRegion: ScriptRegion): vscode.Range {
9090 scriptRegion . endColumnNumber - 1 ) ;
9191}
9292
93+ function toOneBasedPosition ( position : Position ) : Position {
94+ return position . translate ( { lineDelta : 1 , characterDelta : 1 } ) ;
95+ }
96+
9397function editComparer ( leftOperand : ScriptRegion , rightOperand : ScriptRegion ) : number {
9498 if ( leftOperand . startLineNumber < rightOperand . startLineNumber ) {
9599 return - 1 ;
@@ -246,13 +250,14 @@ class PSDocumentFormattingEditProvider implements
246250 }
247251
248252 private getScriptRegion ( document : TextDocument , position : Position , ch : string ) : Thenable < ScriptRegion > {
253+ let oneBasedPosition = toOneBasedPosition ( position ) ;
249254 return this . languageClient . sendRequest (
250255 ScriptRegionRequest . type ,
251256 {
252257 fileUri : document . uri . toString ( ) ,
253258 character : ch ,
254- line : position . line + 1 ,
255- column : position . character + 1
259+ line : oneBasedPosition . line ,
260+ column : oneBasedPosition . character
256261 } ) . then ( ( result : ScriptRegionRequestResult ) => {
257262 if ( result === null ) {
258263 return null ;
@@ -489,4 +494,4 @@ export class DocumentFormatterFeature implements IFeature {
489494 this . rangeFormattingEditProvider . dispose ( ) ;
490495 this . onTypeFormattingEditProvider . dispose ( ) ;
491496 }
492- }
497+ }
0 commit comments