File tree 2 files changed +12
-7
lines changed
2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -274,11 +274,15 @@ module.exports = {
274
274
// of the container
275
275
editor . execCommand ( "insertstring" , "\n" . repeat ( 200 ) ) ;
276
276
277
- var deltaY ;
277
+ var deltaY , row ;
278
278
var initialScrollBy = editor . renderer . scrollBy ;
279
- editor . renderer . scrollBy = function ( varX , varY ) {
279
+ var initialScrollToRow = editor . renderer . scrollToRow ;
280
+ editor . renderer . scrollBy = function ( _ , varY ) {
280
281
deltaY = varY ;
281
282
} ;
283
+ editor . renderer . scrollToRow = function ( varRow ) {
284
+ row = varRow ;
285
+ } ;
282
286
283
287
inline . show ( editor , completions [ 6 ] , "l" ) ;
284
288
editor . renderer . $loop . _flush ( ) ;
@@ -295,8 +299,9 @@ module.exports = {
295
299
296
300
setTimeout ( ( ) => {
297
301
// Should scroll as much as possbile while keeping the cursor on screen
298
- assert . strictEqual ( deltaY , 490 ) ;
302
+ assert . strictEqual ( row , 202 ) ;
299
303
editor . renderer . scrollBy = initialScrollBy ;
304
+ editor . renderer . scrollToRow = initialScrollToRow ;
300
305
done ( ) ;
301
306
} , 50 ) ;
302
307
} , 50 ) ;
Original file line number Diff line number Diff line change @@ -1781,18 +1781,18 @@ class VirtualRenderer {
1781
1781
var el = this . container ;
1782
1782
var height = el . getBoundingClientRect ( ) . height ;
1783
1783
var ghostTextHeight = textLines . length * this . lineHeight ;
1784
- var fitsY = ghostTextHeight < height - pixelPosition . top ;
1784
+ var fitsY = ghostTextHeight < ( height - pixelPosition . top ) ;
1785
1785
1786
1786
// If it fits, no action needed
1787
1787
if ( fitsY ) return ;
1788
1788
1789
1789
// If it can fully fit in the screen, scroll down until it fits on the screen
1790
- // if it cannot fully fit, scroll so that the cursor is at the top of the screen
1791
- // to fit as much as possible .
1790
+ // if it cannot fully fit, scroll so that the row with the cursor
1791
+ // is at the top of the screen .
1792
1792
if ( ghostTextHeight < height ) {
1793
1793
this . scrollBy ( 0 , ( textLines . length - 1 ) * this . lineHeight ) ;
1794
1794
} else {
1795
- this . scrollBy ( 0 , pixelPosition . top ) ;
1795
+ this . scrollToRow ( insertPosition . row ) ;
1796
1796
}
1797
1797
}
1798
1798
You can’t perform that action at this time.
0 commit comments