@@ -90,6 +90,10 @@ function toRange(scriptRegion: ScriptRegion): vscode.Range {
90
90
scriptRegion . endColumnNumber - 1 ) ;
91
91
}
92
92
93
+ function toOneBasedPosition ( position : Position ) : Position {
94
+ return position . translate ( { lineDelta : 1 , characterDelta : 1 } ) ;
95
+ }
96
+
93
97
function editComparer ( leftOperand : ScriptRegion , rightOperand : ScriptRegion ) : number {
94
98
if ( leftOperand . startLineNumber < rightOperand . startLineNumber ) {
95
99
return - 1 ;
@@ -246,13 +250,14 @@ class PSDocumentFormattingEditProvider implements
246
250
}
247
251
248
252
private getScriptRegion ( document : TextDocument , position : Position , ch : string ) : Thenable < ScriptRegion > {
253
+ let oneBasedPosition = toOneBasedPosition ( position ) ;
249
254
return this . languageClient . sendRequest (
250
255
ScriptRegionRequest . type ,
251
256
{
252
257
fileUri : document . uri . toString ( ) ,
253
258
character : ch ,
254
- line : position . line + 1 ,
255
- column : position . character + 1
259
+ line : oneBasedPosition . line ,
260
+ column : oneBasedPosition . character
256
261
} ) . then ( ( result : ScriptRegionRequestResult ) => {
257
262
if ( result === null ) {
258
263
return null ;
@@ -489,4 +494,4 @@ export class DocumentFormatterFeature implements IFeature {
489
494
this . rangeFormattingEditProvider . dispose ( ) ;
490
495
this . onTypeFormattingEditProvider . dispose ( ) ;
491
496
}
492
- }
497
+ }
0 commit comments