diff options
-rw-r--r-- | src/nvim/move.c | 2 | ||||
-rw-r--r-- | src/nvim/plines.c | 7 | ||||
-rw-r--r-- | test/old/testdir/test_diffmode.vim | 14 |
3 files changed, 14 insertions, 9 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c index f3a79c08bf..c055f6baad 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -2464,7 +2464,7 @@ int pagescroll(Direction dir, int count, bool half) if (dir == FORWARD) { int n = plines_correct_topline(curwin, curwin->w_topline, NULL, false, NULL); if (n - count < curwin->w_height_inner && curwin->w_topline < buflen) { - n += plines_m_win(curwin, curwin->w_topline + 1, buflen, true); + n += plines_m_win(curwin, curwin->w_topline + 1, buflen, false); } if (n - count < curwin->w_height_inner) { count = n - curwin->w_height_inner; diff --git a/src/nvim/plines.c b/src/nvim/plines.c index 8734780415..0c55e2fd72 100644 --- a/src/nvim/plines.c +++ b/src/nvim/plines.c @@ -880,14 +880,17 @@ int plines_m_win(win_T *wp, linenr_T first, linenr_T last, bool limit_winheight) { int count = 0; - while (first <= last) { + while (first <= last && (!limit_winheight || count < wp->w_height_inner)) { linenr_T next = first; - count += plines_win_full(wp, first, &next, NULL, false, limit_winheight); + count += plines_win_full(wp, first, &next, NULL, false, false); first = next + 1; } if (first == wp->w_buffer->b_ml.ml_line_count + 1) { count += win_get_fill(wp, first); } + if (limit_winheight && count > wp->w_height_inner) { + return wp->w_height_inner; + } return count; } diff --git a/test/old/testdir/test_diffmode.vim b/test/old/testdir/test_diffmode.vim index 3cc8f97f2f..71483b7469 100644 --- a/test/old/testdir/test_diffmode.vim +++ b/test/old/testdir/test_diffmode.vim @@ -1774,17 +1774,19 @@ endfunc " Ctrl-D reveals filler lines below the last line in the buffer. func Test_diff_eob_halfpage() - 5new + new call setline(1, ['']->repeat(10) + ['a']) diffthis - call assert_true(5, winheight(5)) - 5new + new call setline(1, ['']->repeat(3) + ['a', 'b']) diffthis + resize 5 wincmd j - resize 7 - exe "norm! G\<C-D>" - call assert_equal(6, line('w0')) + resize 5 + norm G + call assert_equal(7, line('w0')) + exe "norm! \<C-D>" + call assert_equal(8, line('w0')) %bwipe! endfunc |