@@ -552,18 +552,23 @@ export class CodeWatcher implements ICodeWatcher {
552
552
}
553
553
editor . selection = selection ;
554
554
} else {
555
+ let newCell : ICellRange | undefined ;
555
556
// full cell range is selected now decide if expanding or contracting?
556
557
if ( isAnchorLessThanActive && startCellIndex < endCellIndex ) {
557
558
// 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 ) ;
560
561
} else {
561
562
// anchor is below active, expand selection by cell above.
562
563
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 ) ;
565
566
}
566
567
}
568
+
569
+ if ( newCell ) {
570
+ editor . revealRange ( newCell . range , TextEditorRevealType . Default ) ;
571
+ }
567
572
}
568
573
}
569
574
@@ -613,20 +618,25 @@ export class CodeWatcher implements ICodeWatcher {
613
618
}
614
619
editor . selection = selection ;
615
620
} else {
621
+ let newCell : ICellRange | undefined ;
616
622
// full cell range is selected now decide if expanding or contracting?
617
623
if ( isAnchorLessEqualActive || startCellIndex === endCellIndex ) {
618
624
// anchor is above active, expand selection by cell below.
619
625
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 ) ;
622
628
}
623
629
} else {
624
630
// anchor is below active, contract selection by cell above.
625
631
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 ) ;
628
634
}
629
635
}
636
+
637
+ if ( newCell ) {
638
+ editor . revealRange ( newCell . range , TextEditorRevealType . Default ) ;
639
+ }
630
640
}
631
641
}
632
642
0 commit comments