@@ -258,7 +258,7 @@ export class CursorMoveCommands {
258258 return CursorState . fromViewState ( cursor . viewState . move ( inSelectionMode , viewPosition . lineNumber , viewPosition . column , 0 ) ) ;
259259 }
260260
261- public static simpleMove ( context : CursorContext , cursors : CursorState [ ] , direction : CursorMove . MoveDirection , inSelectionMode : boolean , value : number , unit : CursorMove . Unit ) : PartialCursorState [ ] | null {
261+ public static simpleMove ( context : CursorContext , cursors : CursorState [ ] , direction : CursorMove . SimpleMoveDirection , inSelectionMode : boolean , value : number , unit : CursorMove . Unit ) : PartialCursorState [ ] | null {
262262 switch ( direction ) {
263263 case CursorMove . Direction . Left : {
264264 if ( unit === CursorMove . Unit . HalfLine ) {
@@ -322,34 +322,31 @@ export class CursorMoveCommands {
322322 }
323323
324324 public static viewportMove ( context : CursorContext , cursors : CursorState [ ] , direction : CursorMove . ViewportDirection , inSelectionMode : boolean , value : number ) : PartialCursorState [ ] | null {
325+ const visibleViewRange = context . getCompletelyVisibleViewRange ( ) ;
325326 switch ( direction ) {
326327 case CursorMove . Direction . ViewPortTop : {
327328 // Move to the nth line start in the viewport (from the top)
328- const cursor = cursors [ 0 ] ;
329- const visibleModelRange = context . getCompletelyVisibleModelRange ( ) ;
329+ const visibleModelRange = context . convertViewRangeToModelRange ( visibleViewRange ) ;
330330 const modelLineNumber = this . _firstLineNumberInRange ( context . model , visibleModelRange , value ) ;
331331 const modelColumn = context . model . getLineFirstNonWhitespaceColumn ( modelLineNumber ) ;
332- return [ this . _moveToModelPosition ( context , cursor , inSelectionMode , modelLineNumber , modelColumn ) ] ;
332+ return [ this . _moveToModelPosition ( context , cursors [ 0 ] , inSelectionMode , modelLineNumber , modelColumn ) ] ;
333333 }
334334 case CursorMove . Direction . ViewPortBottom : {
335335 // Move to the nth line start in the viewport (from the bottom)
336- const cursor = cursors [ 0 ] ;
337- const visibleModelRange = context . getCompletelyVisibleModelRange ( ) ;
336+ const visibleModelRange = context . convertViewRangeToModelRange ( visibleViewRange ) ;
338337 const modelLineNumber = this . _lastLineNumberInRange ( context . model , visibleModelRange , value ) ;
339338 const modelColumn = context . model . getLineFirstNonWhitespaceColumn ( modelLineNumber ) ;
340- return [ this . _moveToModelPosition ( context , cursor , inSelectionMode , modelLineNumber , modelColumn ) ] ;
339+ return [ this . _moveToModelPosition ( context , cursors [ 0 ] , inSelectionMode , modelLineNumber , modelColumn ) ] ;
341340 }
342341 case CursorMove . Direction . ViewPortCenter : {
343342 // Move to the line start in the viewport center
344- const cursor = cursors [ 0 ] ;
345- const visibleModelRange = context . getCompletelyVisibleModelRange ( ) ;
343+ const visibleModelRange = context . convertViewRangeToModelRange ( visibleViewRange ) ;
346344 const modelLineNumber = Math . round ( ( visibleModelRange . startLineNumber + visibleModelRange . endLineNumber ) / 2 ) ;
347345 const modelColumn = context . model . getLineFirstNonWhitespaceColumn ( modelLineNumber ) ;
348- return [ this . _moveToModelPosition ( context , cursor , inSelectionMode , modelLineNumber , modelColumn ) ] ;
346+ return [ this . _moveToModelPosition ( context , cursors [ 0 ] , inSelectionMode , modelLineNumber , modelColumn ) ] ;
349347 }
350348 case CursorMove . Direction . ViewPortIfOutside : {
351349 // Move to a position inside the viewport
352- const visibleViewRange = context . getCompletelyVisibleViewRange ( ) ;
353350 let result : PartialCursorState [ ] = [ ] ;
354351 for ( let i = 0 , len = cursors . length ; i < len ; i ++ ) {
355352 const cursor = cursors [ i ] ;
@@ -770,6 +767,13 @@ export namespace CursorMove {
770767 value : number ;
771768 }
772769
770+ export interface SimpleMoveArguments {
771+ direction : SimpleMoveDirection ;
772+ unit : Unit ;
773+ select : boolean ;
774+ value : number ;
775+ }
776+
773777 export const enum Direction {
774778 Left ,
775779 Right ,
@@ -789,7 +793,7 @@ export namespace CursorMove {
789793 ViewPortIfOutside ,
790794 }
791795
792- export type MoveDirection = (
796+ export type SimpleMoveDirection = (
793797 Direction . Left
794798 | Direction . Right
795799 | Direction . Up
0 commit comments