]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1491: wrong scrolling with ls=0 and :botright split v9.0.1491
authorzeertzjq <zeertzjq@outlook.com>
Wed, 26 Apr 2023 18:01:44 +0000 (19:01 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 26 Apr 2023 18:01:44 +0000 (19:01 +0100)
Problem:    Wrong scrolling with ls=0 and :botright split.
Solution:   Add statusline before calling frame_new_height(). (closes #12299)

src/testdir/test_window_cmd.vim
src/version.c
src/window.c

index 3d29266505bafc79a59f858e79cafe93a16b40b4..a3889de26a91f8fbd026c0638a87dba5d63635a5 100644 (file)
@@ -19,6 +19,24 @@ func Test_window_cmd_ls0_with_split()
   set ls&vim
 endfunc
 
+func Test_window_cmd_ls0_split_scrolling()
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+    set laststatus=0
+    call setline(1, range(1, 100))
+    normal! G
+  END
+  call writefile(lines, 'XTestLs0SplitScrolling', 'D')
+  let buf = RunVimInTerminal('-S XTestLs0SplitScrolling', #{rows: 10})
+
+  call term_sendkeys(buf, ":botright split\<CR>")
+  call WaitForAssert({-> assert_match('Bot$', term_getline(buf, 5))})
+  call assert_equal('100', term_getline(buf, 4))
+
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_window_cmd_cmdwin_with_vsp()
   let efmt = 'Expected 0 but got %d (in ls=%d, %s window)'
   for v in range(0, 2)
index e5a6ada0c2f2972ed72b242b7ea7694735afe11e..1ae97f646e4209a85fd5db2596e43a4741c0486d 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1491,
 /**/
     1490,
 /**/
index 6b86825a440c2145b032a641182c01b1018c4b12..244ee37d86b054bd0341a00e21ab825b55b58b2c 100644 (file)
@@ -1307,6 +1307,7 @@ win_split_ins(
        // "new_size" of the current window goes to the new window, use
        // one row for the status line
        win_new_height(wp, new_size);
+       int old_status_height = oldwin->w_status_height;
        if (flags & (WSP_TOP | WSP_BOT))
        {
            int new_fr_height = curfrp->fr_height - new_size
@@ -1314,6 +1315,8 @@ win_split_ins(
 
            if (!((flags & WSP_BOT) && p_ls == 0))
                new_fr_height -= STATUS_HEIGHT;
+           if (flags & WSP_BOT)
+               frame_add_statusline(curfrp);
            frame_new_height(curfrp, new_fr_height, flags & WSP_TOP, FALSE);
        }
        else
@@ -1328,12 +1331,10 @@ win_split_ins(
        {
            wp->w_winrow = oldwin->w_winrow + VISIBLE_HEIGHT(oldwin)
                                                               + STATUS_HEIGHT;
-           wp->w_status_height = oldwin->w_status_height;
+           wp->w_status_height = old_status_height;
            if (!(flags & WSP_BOT))
                oldwin->w_status_height = STATUS_HEIGHT;
        }
-       if (flags & WSP_BOT)
-           frame_add_statusline(curfrp);
        frame_fix_height(wp);
        frame_fix_height(oldwin);
     }
@@ -3791,12 +3792,7 @@ frame_add_statusline(frame_T *frp)
     if (frp->fr_layout == FR_LEAF)
     {
        wp = frp->fr_win;
-       if (wp->w_status_height == 0)
-       {
-           if (wp->w_height > 0)       // don't make it negative
-               --wp->w_height;
-           wp->w_status_height = STATUS_HEIGHT;
-       }
+       wp->w_status_height = STATUS_HEIGHT;
     }
     else if (frp->fr_layout == FR_ROW)
     {