vim-patch:9.1.0294: Text height function does not respect it's argument

Problem:  plines_m_win() does not take into account it's "limit_winheight"
          argument for filler lines below the last line of the buffer.
          (after v9.1.0280)
Solution: Check window height when "limit_winheight" is TRUE.
          (Luuk van Baal)

08b0f632c1
This commit is contained in:
Luuk van Baal 2024-04-09 23:19:17 +02:00
parent 832857ae09
commit d4956e16d9
3 changed files with 14 additions and 9 deletions

View File

@ -2464,7 +2464,7 @@ int pagescroll(Direction dir, int count, bool half)
if (dir == FORWARD) { if (dir == FORWARD) {
int n = plines_correct_topline(curwin, curwin->w_topline, NULL, false, NULL); int n = plines_correct_topline(curwin, curwin->w_topline, NULL, false, NULL);
if (n - count < curwin->w_height_inner && curwin->w_topline < buflen) { 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) { if (n - count < curwin->w_height_inner) {
count = n - curwin->w_height_inner; count = n - curwin->w_height_inner;

View File

@ -880,14 +880,17 @@ int plines_m_win(win_T *wp, linenr_T first, linenr_T last, bool limit_winheight)
{ {
int count = 0; int count = 0;
while (first <= last) { while (first <= last && (!limit_winheight || count < wp->w_height_inner)) {
linenr_T next = first; 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; first = next + 1;
} }
if (first == wp->w_buffer->b_ml.ml_line_count + 1) { if (first == wp->w_buffer->b_ml.ml_line_count + 1) {
count += win_get_fill(wp, first); count += win_get_fill(wp, first);
} }
if (limit_winheight && count > wp->w_height_inner) {
return wp->w_height_inner;
}
return count; return count;
} }

View File

@ -1774,17 +1774,19 @@ endfunc
" Ctrl-D reveals filler lines below the last line in the buffer. " Ctrl-D reveals filler lines below the last line in the buffer.
func Test_diff_eob_halfpage() func Test_diff_eob_halfpage()
5new new
call setline(1, ['']->repeat(10) + ['a']) call setline(1, ['']->repeat(10) + ['a'])
diffthis diffthis
call assert_true(5, winheight(5)) new
5new
call setline(1, ['']->repeat(3) + ['a', 'b']) call setline(1, ['']->repeat(3) + ['a', 'b'])
diffthis diffthis
resize 5
wincmd j wincmd j
resize 7 resize 5
exe "norm! G\<C-D>" norm G
call assert_equal(6, line('w0')) call assert_equal(7, line('w0'))
exe "norm! \<C-D>"
call assert_equal(8, line('w0'))
%bwipe! %bwipe!
endfunc endfunc