@@ -17,6 +17,7 @@ import * as platform from '../../../base/common/platform.js';
1717import { StandardTokenType } from '../../common/encodedTokenAttributes.js' ;
1818import { ITextModel } from '../../common/model.js' ;
1919import { containsRTL } from '../../../base/common/strings.js' ;
20+ import { CursorColumns } from '../../common/core/cursorColumns.js' ;
2021
2122export interface IMouseDispatchData {
2223 position : Position ;
@@ -286,7 +287,7 @@ export class ViewController {
286287 } else {
287288 // Do multi-cursor operations only when purely alt is pressed
288289 if ( data . inSelectionMode ) {
289- this . _lastCursorMoveToSelect ( data . position , data . revealType ) ;
290+ this . _lastCursorMoveToSelect ( data . position , data . mouseColumn , data . revealType ) ;
290291 } else {
291292 this . _createCursor ( data . position , false ) ;
292293 }
@@ -300,32 +301,63 @@ export class ViewController {
300301 if ( columnSelection ) {
301302 this . _columnSelect ( data . position , data . mouseColumn , true ) ;
302303 } else {
303- this . _moveToSelect ( data . position , data . revealType ) ;
304+ this . _moveToSelect ( data . position , data . mouseColumn , data . revealType ) ;
304305 }
305306 }
306307 } else {
307- this . moveTo ( data . position , data . revealType ) ;
308+ this . moveTo ( data . position , data . mouseColumn , data . revealType ) ;
308309 }
309310 }
310311 }
311312 }
312313
313- private _usualArgs ( viewPosition : Position , revealType : NavigationCommandRevealType ) : CoreNavigationCommands . MoveCommandOptions {
314+ private _usualArgs ( viewPosition : Position , revealType : NavigationCommandRevealType ) : CoreNavigationCommands . MoveCommandOptions ;
315+ private _usualArgs ( viewPosition : Position , mouseColumn : number , revealType : NavigationCommandRevealType ) : CoreNavigationCommands . MoveCommandOptions ;
316+ private _usualArgs ( viewPosition : Position , arg2 : number | NavigationCommandRevealType , arg3 ?: NavigationCommandRevealType ) : CoreNavigationCommands . MoveCommandOptions {
314317 viewPosition = this . _validateViewColumn ( viewPosition ) ;
318+ let mouseColumn : number ;
319+ let revealType : NavigationCommandRevealType ;
320+ if ( arg3 !== undefined ) {
321+ mouseColumn = arg2 as number ;
322+ revealType = arg3 ;
323+ } else {
324+ mouseColumn = CursorColumns . visibleColumnFromColumn ( this . viewModel . getLineContent ( viewPosition . lineNumber ) , viewPosition . column , this . viewModel . model . getOptions ( ) . tabSize ) + 1 ;
325+ revealType = arg2 as NavigationCommandRevealType ;
326+ }
327+
328+ let leftoverVisibleColumns = 0 ;
329+ if ( this . configuration . options . get ( EditorOption . virtualSpace ) ) {
330+ const maxColumn = this . viewModel . getLineMaxColumn ( viewPosition . lineNumber ) ;
331+ const maxVisibleColumn = CursorColumns . visibleColumnFromColumn ( this . viewModel . getLineContent ( viewPosition . lineNumber ) , maxColumn , this . viewModel . model . getOptions ( ) . tabSize ) ;
332+ leftoverVisibleColumns = Math . max ( 0 , ( mouseColumn - 1 ) - maxVisibleColumn ) ;
333+ }
315334 return {
316335 source : 'mouse' ,
317336 position : this . _convertViewToModelPosition ( viewPosition ) ,
318337 viewPosition,
338+ leftoverVisibleColumns,
319339 revealType
320340 } ;
321341 }
322342
323- public moveTo ( viewPosition : Position , revealType : NavigationCommandRevealType ) : void {
324- CoreNavigationCommands . MoveTo . runCoreEditorCommand ( this . viewModel , this . _usualArgs ( viewPosition , revealType ) ) ;
343+ public moveTo ( viewPosition : Position , revealType : NavigationCommandRevealType ) : void ;
344+ public moveTo ( viewPosition : Position , mouseColumn : number , revealType : NavigationCommandRevealType ) : void ;
345+ public moveTo ( viewPosition : Position , arg2 : number | NavigationCommandRevealType , arg3 ?: NavigationCommandRevealType ) : void {
346+ if ( arg3 !== undefined ) {
347+ CoreNavigationCommands . MoveTo . runCoreEditorCommand ( this . viewModel , this . _usualArgs ( viewPosition , arg2 as number , arg3 ) ) ;
348+ } else {
349+ CoreNavigationCommands . MoveTo . runCoreEditorCommand ( this . viewModel , this . _usualArgs ( viewPosition , arg2 as NavigationCommandRevealType ) ) ;
350+ }
325351 }
326352
327- private _moveToSelect ( viewPosition : Position , revealType : NavigationCommandRevealType ) : void {
328- CoreNavigationCommands . MoveToSelect . runCoreEditorCommand ( this . viewModel , this . _usualArgs ( viewPosition , revealType ) ) ;
353+ private _moveToSelect ( viewPosition : Position , revealType : NavigationCommandRevealType ) : void ;
354+ private _moveToSelect ( viewPosition : Position , mouseColumn : number , revealType : NavigationCommandRevealType ) : void ;
355+ private _moveToSelect ( viewPosition : Position , arg2 : number | NavigationCommandRevealType , arg3 ?: NavigationCommandRevealType ) : void {
356+ if ( arg3 !== undefined ) {
357+ CoreNavigationCommands . MoveToSelect . runCoreEditorCommand ( this . viewModel , this . _usualArgs ( viewPosition , arg2 as number , arg3 ) ) ;
358+ } else {
359+ CoreNavigationCommands . MoveToSelect . runCoreEditorCommand ( this . viewModel , this . _usualArgs ( viewPosition , arg2 as NavigationCommandRevealType ) ) ;
360+ }
329361 }
330362
331363 private _columnSelect ( viewPosition : Position , mouseColumn : number , doColumnSelect : boolean ) : void {
@@ -349,8 +381,14 @@ export class ViewController {
349381 } ) ;
350382 }
351383
352- private _lastCursorMoveToSelect ( viewPosition : Position , revealType : NavigationCommandRevealType ) : void {
353- CoreNavigationCommands . LastCursorMoveToSelect . runCoreEditorCommand ( this . viewModel , this . _usualArgs ( viewPosition , revealType ) ) ;
384+ private _lastCursorMoveToSelect ( viewPosition : Position , revealType : NavigationCommandRevealType ) : void ;
385+ private _lastCursorMoveToSelect ( viewPosition : Position , mouseColumn : number , revealType : NavigationCommandRevealType ) : void ;
386+ private _lastCursorMoveToSelect ( viewPosition : Position , arg2 : number | NavigationCommandRevealType , arg3 ?: NavigationCommandRevealType ) : void {
387+ if ( arg3 !== undefined ) {
388+ CoreNavigationCommands . LastCursorMoveToSelect . runCoreEditorCommand ( this . viewModel , this . _usualArgs ( viewPosition , arg2 as number , arg3 ) ) ;
389+ } else {
390+ CoreNavigationCommands . LastCursorMoveToSelect . runCoreEditorCommand ( this . viewModel , this . _usualArgs ( viewPosition , arg2 as NavigationCommandRevealType ) ) ;
391+ }
354392 }
355393
356394 private _wordSelect ( viewPosition : Position , revealType : NavigationCommandRevealType ) : void {
0 commit comments