@@ -589,14 +589,19 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
589589 if ( boxEndY - boxStartY > viewportHeight ) {
590590 // the box is larger than the viewport ... scroll to its top
591591 newScrollTop = boxStartY ;
592- } else if ( verticalType === viewEvents . VerticalRevealType . NearTop ) {
593- // We want a gap that is 20% of the viewport, but with a minimum of 5 lines
594- const desiredGapAbove = Math . max ( 5 * this . _lineHeight , viewportHeight * 0.2 ) ;
595- // Try to scroll just above the box with the desired gap
596- const desiredScrollTop = boxStartY - desiredGapAbove ;
597- // But ensure that the box is not pushed out of viewport
598- const minScrollTop = boxEndY - viewportHeight ;
599- newScrollTop = Math . max ( minScrollTop , desiredScrollTop ) ;
592+ } else if ( verticalType === viewEvents . VerticalRevealType . NearTop || verticalType === viewEvents . VerticalRevealType . NearTopIfOutsideViewport ) {
593+ if ( verticalType === viewEvents . VerticalRevealType . NearTopIfOutsideViewport && viewportStartY <= boxStartY && boxEndY <= viewportEndY ) {
594+ // Box is already in the viewport... do nothing
595+ newScrollTop = viewportStartY ;
596+ } else {
597+ // We want a gap that is 20% of the viewport, but with a minimum of 5 lines
598+ const desiredGapAbove = Math . max ( 5 * this . _lineHeight , viewportHeight * 0.2 ) ;
599+ // Try to scroll just above the box with the desired gap
600+ const desiredScrollTop = boxStartY - desiredGapAbove ;
601+ // But ensure that the box is not pushed out of viewport
602+ const minScrollTop = boxEndY - viewportHeight ;
603+ newScrollTop = Math . max ( minScrollTop , desiredScrollTop ) ;
604+ }
600605 } else if ( verticalType === viewEvents . VerticalRevealType . Center || verticalType === viewEvents . VerticalRevealType . CenterIfOutsideViewport ) {
601606 if ( verticalType === viewEvents . VerticalRevealType . CenterIfOutsideViewport && viewportStartY <= boxStartY && boxEndY <= viewportEndY ) {
602607 // Box is already in the viewport... do nothing
0 commit comments