@@ -11,6 +11,7 @@ import { SelectionModel } from 'browser/selection/SelectionModel';
11
11
import { CellData } from 'common/buffer/CellData' ;
12
12
import { EventEmitter , IEvent } from 'common/EventEmitter' ;
13
13
import { ICharSizeService , IMouseService , ISelectionService , IRenderService } from 'browser/services/Services' ;
14
+ import { ILinkifier2 } from 'browser/Types' ;
14
15
import { IBufferService , IOptionsService , ICoreService } from 'common/services/Services' ;
15
16
import { getCoordsRelativeToElement } from 'browser/input/Mouse' ;
16
17
import { moveToCellSequence } from 'browser/input/MoveToCell' ;
@@ -121,6 +122,7 @@ export class SelectionService extends Disposable implements ISelectionService {
121
122
constructor (
122
123
private readonly _element : HTMLElement ,
123
124
private readonly _screenElement : HTMLElement ,
125
+ private readonly _linkifier : ILinkifier2 ,
124
126
@IBufferService private readonly _bufferService : IBufferService ,
125
127
@ICoreService private readonly _coreService : ICoreService ,
126
128
@IMouseService private readonly _mouseService : IMouseService ,
@@ -316,13 +318,22 @@ export class SelectionService extends Disposable implements ISelectionService {
316
318
* Selects word at the current mouse event coordinates.
317
319
* @param event The mouse event.
318
320
*/
319
- private _selectWordAtCursor ( event : MouseEvent ) : void {
321
+ private _selectWordAtCursor ( event : MouseEvent , allowWhitespaceOnlySelection : boolean ) : boolean {
322
+ const range = this . _linkifier . currentLink ?. link ?. range ;
323
+ if ( range ) {
324
+ const scrollOffset = this . _bufferService . buffer . ydisp ;
325
+ this . _model . selectionStart = [ range . start . x - 1 , range . start . y - scrollOffset - 1 ] ;
326
+ this . _model . selectionEnd = [ range . end . x , range . end . y - scrollOffset - 1 ] ;
327
+ return true ;
328
+ }
329
+
320
330
const coords = this . _getMouseBufferCoords ( event ) ;
321
331
if ( coords ) {
322
- this . _selectWordAt ( coords , false ) ;
332
+ this . _selectWordAt ( coords , allowWhitespaceOnlySelection ) ;
323
333
this . _model . selectionEnd = undefined ;
324
- this . refresh ( true ) ;
334
+ return true ;
325
335
}
336
+ return false ;
326
337
}
327
338
328
339
/**
@@ -527,14 +538,12 @@ export class SelectionService extends Disposable implements ISelectionService {
527
538
}
528
539
529
540
/**
530
- * Performs a double click, selecting the current work .
541
+ * Performs a double click, selecting the current word .
531
542
* @param event The mouse event.
532
543
*/
533
544
private _onDoubleClick ( event : MouseEvent ) : void {
534
- const coords = this . _getMouseBufferCoords ( event ) ;
535
- if ( coords ) {
545
+ if ( this . _selectWordAtCursor ( event , true ) ) {
536
546
this . _activeSelectionMode = SelectionMode . WORD ;
537
- this . _selectWordAt ( coords , true ) ;
538
547
}
539
548
}
540
549
@@ -764,7 +773,9 @@ export class SelectionService extends Disposable implements ISelectionService {
764
773
765
774
public rightClickSelect ( ev : MouseEvent ) : void {
766
775
if ( ! this . _isClickInSelection ( ev ) ) {
767
- this . _selectWordAtCursor ( ev ) ;
776
+ if ( this . _selectWordAtCursor ( ev , false ) ) {
777
+ this . refresh ( true ) ;
778
+ }
768
779
this . _fireEventIfSelectionChanged ( ) ;
769
780
}
770
781
}
0 commit comments