@@ -30,6 +30,19 @@ import { SmartQuoteMatcher, WhichQuotes } from './plugins/targets/smartQuotesMat
3030import { useSmartQuotes } from './plugins/targets/targetsConfig' ;
3131import { ModeDataFor } from '../mode/modeData' ;
3232
33+ function adjustForDesiredColumn ( args : {
34+ position : Position ;
35+ desiredColumn : number ;
36+ multicursorIndex : number | undefined ;
37+ } ) : Position {
38+ const { position, desiredColumn, multicursorIndex } = args ;
39+ // HACK: until we put `desiredColumn` on `Cursor`, only the first cursor will respect it (except after `$`)
40+ if ( multicursorIndex && multicursorIndex > 0 && desiredColumn !== Number . POSITIVE_INFINITY ) {
41+ return position ;
42+ }
43+ return position . with ( { character : desiredColumn } ) ;
44+ }
45+
3346/**
3447 * A movement is something like 'h', 'k', 'w', 'b', 'gg', etc.
3548 */
@@ -284,7 +297,11 @@ class MoveDownFoldFix extends MoveByScreenLineMaintainDesiredColumn {
284297 }
285298 prev = t ;
286299 }
287- return t . with ( { character : vimState . desiredColumn } ) ;
300+ return adjustForDesiredColumn ( {
301+ position : t ,
302+ desiredColumn : vimState . desiredColumn ,
303+ multicursorIndex : this . multicursorIndex ,
304+ } ) ;
288305 }
289306}
290307
@@ -313,10 +330,13 @@ class MoveDown extends BaseMovement {
313330 }
314331
315332 if ( position . line < vimState . document . lineCount - 1 ) {
316- return position . with ( { character : vimState . desiredColumn } ) . getDown ( ) ;
317- } else {
318- return position ;
333+ return adjustForDesiredColumn ( {
334+ position,
335+ desiredColumn : vimState . desiredColumn ,
336+ multicursorIndex : this . multicursorIndex ,
337+ } ) . getDown ( ) ;
319338 }
339+ return position ;
320340 }
321341
322342 public override async execActionForOperator (
@@ -353,10 +373,13 @@ class MoveUp extends BaseMovement {
353373 }
354374
355375 if ( position . line > 0 ) {
356- return position . with ( { character : vimState . desiredColumn } ) . getUp ( ) ;
357- } else {
358- return position ;
376+ return adjustForDesiredColumn ( {
377+ position,
378+ desiredColumn : vimState . desiredColumn ,
379+ multicursorIndex : this . multicursorIndex ,
380+ } ) . getUp ( ) ;
359381 }
382+ return position ;
360383 }
361384
362385 public override async execActionForOperator (
@@ -392,7 +415,11 @@ class MoveUpFoldFix extends MoveByScreenLineMaintainDesiredColumn {
392415 }
393416 prev = t ;
394417 }
395- return t . with ( { character : vimState . desiredColumn } ) ;
418+ return adjustForDesiredColumn ( {
419+ position : t ,
420+ desiredColumn : vimState . desiredColumn ,
421+ multicursorIndex : this . multicursorIndex ,
422+ } ) ;
396423 }
397424}
398425
@@ -1201,10 +1228,13 @@ class MoveUpByScreenLineVisualBlock extends BaseMovement {
12011228 vimState : VimState ,
12021229 ) : Promise < Position | IMovement > {
12031230 if ( position . line > 0 ) {
1204- return position . with ( { character : vimState . desiredColumn } ) . getUp ( ) ;
1205- } else {
1206- return position ;
1231+ return adjustForDesiredColumn ( {
1232+ position,
1233+ desiredColumn : vimState . desiredColumn ,
1234+ multicursorIndex : this . multicursorIndex ,
1235+ } ) . getUp ( ) ;
12071236 }
1237+ return position ;
12081238 }
12091239
12101240 public override async execActionForOperator (
@@ -1230,10 +1260,13 @@ class MoveDownByScreenLineVisualBlock extends BaseMovement {
12301260 vimState : VimState ,
12311261 ) : Promise < Position | IMovement > {
12321262 if ( position . line < vimState . document . lineCount - 1 ) {
1233- return position . with ( { character : vimState . desiredColumn } ) . getDown ( ) ;
1234- } else {
1235- return position ;
1263+ return adjustForDesiredColumn ( {
1264+ position,
1265+ desiredColumn : vimState . desiredColumn ,
1266+ multicursorIndex : this . multicursorIndex ,
1267+ } ) . getDown ( ) ;
12361268 }
1269+ return position ;
12371270 }
12381271
12391272 public override async execActionForOperator (
0 commit comments