]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0294: Text height function does not respect it's argument v9.1.0294
authorLuuk van Baal <luukvbaal@gmail.com>
Tue, 9 Apr 2024 20:43:49 +0000 (22:43 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 9 Apr 2024 20:43:49 +0000 (22:43 +0200)
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)

closes: #14449

Signed-off-by: Luuk van Baal <luukvbaal@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/misc1.c
src/move.c
src/popupwin.c
src/testdir/test_diffmode.vim
src/version.c

index 7ee471233bf1e5b1d7f7acd41f11ecd1f89a4c14..c5a0c385271e2fec9dcb4878ddf4cbaa00cdd511 100644 (file)
@@ -502,7 +502,7 @@ plines_m_win(win_T *wp, linenr_T first, linenr_T last, int limit_winheight)
 {
     int                count = 0;
 
-    while (first <= last)
+    while (first <= last && (!limit_winheight || count < wp->w_height))
     {
 #ifdef FEAT_FOLDING
        int     x;
@@ -519,17 +519,20 @@ plines_m_win(win_T *wp, linenr_T first, linenr_T last, int limit_winheight)
 #endif
        {
 #ifdef FEAT_DIFF
-           if (first == wp->w_buffer->b_ml.ml_line_count)
-               count += diff_check_fill(wp, first + 1);
            if (first == wp->w_topline)
-               count += plines_win_nofill(wp, first, limit_winheight)
-                                                              + wp->w_topfill;
+               count += plines_win_nofill(wp, first, FALSE) + wp->w_topfill;
            else
 #endif
-               count += plines_win(wp, first, limit_winheight);
+               count += plines_win(wp, first, FALSE);
            ++first;
        }
     }
+#ifdef FEAT_DIFF
+    if (first == wp->w_buffer->b_ml.ml_line_count + 1)
+       count += diff_check_fill(wp, first);
+#endif
+    if (limit_winheight && count > wp->w_height)
+       return wp->w_height;
     return (count);
 }
 
index 9853b0b8dadf235fe75e62d4c302a451ffbc7553..8c6fbd6b88cbbb00d30d9f7b7f2bac1f77f8e2f8 100644 (file)
@@ -3210,7 +3210,7 @@ pagescroll(int dir, long count, int half)
        {
            int n = plines_correct_topline(curwin, curwin->w_topline, FALSE);
            if (n - count < curwin->w_height && 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)
                count = n - curwin->w_height;
        }
index bdf4ac7cfdbb72bf3a113bb3bfc34de542a2dd27..25bb15349e59d3c642738fd16fbb8620636d181c 100644 (file)
@@ -654,7 +654,7 @@ popup_show_curline(win_T *wp)
            wp->w_topline = wp->w_buffer->b_ml.ml_line_count;
        while (wp->w_topline < wp->w_cursor.lnum
                && wp->w_topline < wp->w_buffer->b_ml.ml_line_count
-               && plines_m_win(wp, wp->w_topline, wp->w_cursor.lnum, TRUE)
+               && plines_m_win(wp, wp->w_topline, wp->w_cursor.lnum, FALSE)
                                                                > wp->w_height)
            ++wp->w_topline;
     }
index f28e840ac57e8f2e70f8c340e217147652688400..098d5d0fc67c9085d76a68f2c90d4c9add429775 100644 (file)
@@ -2025,17 +2025,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
index 70f1425a3b6bf6303ea7aab312476e86e4d93a48..f39d30a1d327887c2ef3f08fc63e02001bf43920 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    294,
 /**/
     293,
 /**/