@@ -169,7 +169,7 @@ class RobotVscode implements Robot {
169169
170170 if ( editor == null ) return rej ( e )
171171
172- function MoveCursor ( options : any ) {
172+ function moveCursor ( options : any ) {
173173 if ( options . value === 0 ) return res ( )
174174
175175 return vscode . commands . executeCommand ( 'cursorMove' , options ) . then ( ( ) => res ( ) )
@@ -180,12 +180,12 @@ class RobotVscode implements Robot {
180180 if ( to === 'BEGIN_LINE' || to === 'END_LINE' ) {
181181 const { relative } = this . lineBoundaries ( currentLine )
182182
183- return MoveCursor ( { to : relative [ to === 'BEGIN_LINE' ? 0 : 1 ] } )
183+ return moveCursor ( { to : relative [ to === 'BEGIN_LINE' ? 0 : 1 ] } )
184184 }
185185
186186 // Move the cursor {leapSize} units to the right
187187 if ( to === null ) {
188- return MoveCursor ( { to : 'right' , value : leapSize , by : 'character' } )
188+ return moveCursor ( { to : 'right' , value : leapSize , by : 'character' } )
189189 }
190190
191191 if ( to === 'SYMBOL' && symbol != undefined ) {
@@ -200,7 +200,7 @@ class RobotVscode implements Robot {
200200
201201 if ( range == null ) return rej ( 'Match not found for symbol: ' + symbol )
202202
203- return MoveCursor ( { to : 'right' , value : range [ 0 ] , by : 'character' } )
203+ return moveCursor ( { to : 'right' , value : range [ 0 ] , by : 'character' } )
204204 }
205205
206206 return rej ( new Error ( 'Unknown operation!' ) )
@@ -303,14 +303,20 @@ class RobotVscode implements Robot {
303303 * @param p2 Finish string[] (line, cursor)
304304 */
305305 indentSelection = (
306- p1 : [ string , string ] ,
307- p2 : [ string , string ]
306+ p1 ? : [ string , string ] ,
307+ p2 ? : [ string , string ]
308308 ) => new Promise < void | Error > ( ( res , rej ) => {
309309 try {
310310 const editor = vscode . window . activeTextEditor
311311
312312 if ( editor == null ) return rej ( new Error ( 'No active text editor' ) )
313313
314+ if ( p1 == null || p2 == null ) {
315+ return vscode . commands . executeCommand ( 'editor.action.formatDocument' , { } ) . then ( a => {
316+ res ( )
317+ } )
318+ }
319+
314320 p1 [ 0 ] = p1 [ 0 ] ?? editor . selection . active . line
315321 p2 [ 0 ] = p2 [ 0 ] ?? editor . selection . active . line
316322
0 commit comments