@@ -685,23 +685,22 @@ export class SelectionService extends Disposable implements ISelectionService {
685685 }
686686 }
687687 } else {
688- this . _fireIfSelectionChanged ( ) ;
688+ this . _fireEventIfSelectionChanged ( ) ;
689689 }
690690 }
691691
692- private _fireIfSelectionChanged ( ) : void {
693- // Fire if there is no selection
694- const hasSelection = this . hasSelection ;
692+ private _fireEventIfSelectionChanged ( ) : void {
693+ const start = this . _model . finalSelectionStart ;
694+ const end = this . _model . finalSelectionEnd ;
695+ const hasSelection = ! ! start && ! ! end && ( start [ 0 ] !== end [ 0 ] || start [ 1 ] !== end [ 1 ] ) ;
696+
695697 if ( ! hasSelection ) {
696698 if ( this . _oldHasSelection ) {
697- this . _onSelectionChange . fire ( ) ;
699+ this . _fireOnSelectionChange ( start , end , hasSelection ) ;
698700 }
699701 return ;
700702 }
701703
702- const start = this . _model . finalSelectionStart ;
703- const end = this . _model . finalSelectionEnd ;
704-
705704 // Sanity check, these should not be undefined as there is a selection
706705 if ( ! start || ! end ) {
707706 return ;
@@ -711,13 +710,17 @@ export class SelectionService extends Disposable implements ISelectionService {
711710 start [ 0 ] !== this . _oldSelectionStart [ 0 ] || start [ 1 ] !== this . _oldSelectionStart [ 1 ] ||
712711 end [ 0 ] !== this . _oldSelectionEnd [ 0 ] || end [ 1 ] !== this . _oldSelectionEnd [ 1 ] ) ) {
713712
714- this . _oldSelectionStart = start ;
715- this . _oldSelectionEnd = end ;
716- this . _oldHasSelection = hasSelection ;
717- this . _onSelectionChange . fire ( ) ;
713+ this . _fireOnSelectionChange ( start , end , hasSelection ) ;
718714 }
719715 }
720716
717+ private _fireOnSelectionChange ( start : [ number , number ] | undefined , end : [ number , number ] | undefined , hasSelection : boolean ) : void {
718+ this . _oldSelectionStart = start ;
719+ this . _oldSelectionEnd = end ;
720+ this . _oldHasSelection = hasSelection ;
721+ this . _onSelectionChange . fire ( ) ;
722+ }
723+
721724 private _onBufferActivate ( e : { activeBuffer : IBuffer , inactiveBuffer : IBuffer } ) : void {
722725 this . clearSelection ( ) ;
723726 // Only adjust the selection on trim, shiftElements is rarely used (only in
@@ -762,7 +765,7 @@ export class SelectionService extends Disposable implements ISelectionService {
762765 public rightClickSelect ( ev : MouseEvent ) : void {
763766 if ( ! this . _isClickInSelection ( ev ) ) {
764767 this . _selectWordAtCursor ( ev ) ;
765- this . _fireIfSelectionChanged ( ) ;
768+ this . _fireEventIfSelectionChanged ( ) ;
766769 }
767770 }
768771
0 commit comments