@@ -552,18 +552,23 @@ export class CodeWatcher implements ICodeWatcher {
552552 }
553553 editor . selection = selection ;
554554 } else {
555+ let newCell : ICellRange | undefined ;
555556 // full cell range is selected now decide if expanding or contracting?
556557 if ( isAnchorLessThanActive && startCellIndex < endCellIndex ) {
557558 // anchor is above active, contract selection by cell below.
558- const newEndCell = cells [ endCellIndex - 1 ] ;
559- editor . selection = new Selection ( startCell . range . start , newEndCell . range . end ) ;
559+ newCell = cells [ endCellIndex - 1 ] ;
560+ editor . selection = new Selection ( startCell . range . start , newCell . range . end ) ;
560561 } else {
561562 // anchor is below active, expand selection by cell above.
562563 if ( startCellIndex > 0 ) {
563- const aboveCell = cells [ startCellIndex - 1 ] ;
564- editor . selection = new Selection ( endCell . range . end , aboveCell . range . start ) ;
564+ newCell = cells [ startCellIndex - 1 ] ;
565+ editor . selection = new Selection ( endCell . range . end , newCell . range . start ) ;
565566 }
566567 }
568+
569+ if ( newCell ) {
570+ editor . revealRange ( newCell . range , TextEditorRevealType . Default ) ;
571+ }
567572 }
568573 }
569574
@@ -613,20 +618,25 @@ export class CodeWatcher implements ICodeWatcher {
613618 }
614619 editor . selection = selection ;
615620 } else {
621+ let newCell : ICellRange | undefined ;
616622 // full cell range is selected now decide if expanding or contracting?
617623 if ( isAnchorLessEqualActive || startCellIndex === endCellIndex ) {
618624 // anchor is above active, expand selection by cell below.
619625 if ( endCellIndex < cells . length - 1 ) {
620- const extendCell = cells [ endCellIndex + 1 ] ;
621- editor . selection = new Selection ( startCell . range . start , extendCell . range . end ) ;
626+ newCell = cells [ endCellIndex + 1 ] ;
627+ editor . selection = new Selection ( startCell . range . start , newCell . range . end ) ;
622628 }
623629 } else {
624630 // anchor is below active, contract selection by cell above.
625631 if ( startCellIndex < endCellIndex ) {
626- const contractCell = cells [ startCellIndex + 1 ] ;
627- editor . selection = new Selection ( endCell . range . end , contractCell . range . start ) ;
632+ newCell = cells [ startCellIndex + 1 ] ;
633+ editor . selection = new Selection ( endCell . range . end , newCell . range . start ) ;
628634 }
629635 }
636+
637+ if ( newCell ) {
638+ editor . revealRange ( newCell . range , TextEditorRevealType . Default ) ;
639+ }
630640 }
631641 }
632642
0 commit comments