]> granicus.if.org Git - vim/commitdiff
patch 8.2.4984: dragging statusline fails for window with winbar v8.2.4984
authorzeertzjq <zeertzjq@outlook.com>
Fri, 20 May 2022 12:45:59 +0000 (13:45 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 20 May 2022 12:45:59 +0000 (13:45 +0100)
Problem:    Dragging statusline fails for window with winbar.
Solution:   Fix off-by-one error. (closes #10448)

src/mouse.c
src/testdir/test_winbar.vim
src/version.c

index af9186d72ffc8e8c724dabe454a16d35c258fb93..58c4ab4ec68f11a7427c56528db44c4d3a0f1728 100644 (file)
@@ -1823,7 +1823,7 @@ retnomove:
        if (dragwin != NULL)
        {
            // Drag the status line
-           count = row - dragwin->w_winrow - dragwin->w_height + 1
+           count = row - W_WINROW(dragwin) - dragwin->w_height + 1
                                                             - on_status_line;
            win_drag_status_line(dragwin, count);
            did_drag |= count;
index 92da3128f64bc27271f5a7ddb51a378bca69eeb7..7972bc3b635903146e1297e4fc065946dd0a5483 100644 (file)
@@ -161,4 +161,32 @@ func Test_winbar_not_visible_custom_statusline()
   call delete('XtestWinbarNotVisble')
 endfunction
 
+func Test_drag_statusline_with_winbar()
+  call SetupWinbar()
+  let save_mouse = &mouse
+  set mouse=a
+  set laststatus=2
+
+  call test_setmouse(&lines - 1, 1)
+  call feedkeys("\<LeftMouse>", 'xt')
+  call test_setmouse(&lines - 2, 1)
+  call feedkeys("\<LeftDrag>", 'xt')
+  call assert_equal(2, &cmdheight)
+
+  call test_setmouse(&lines - 2, 1)
+  call feedkeys("\<LeftMouse>", 'xt')
+  call test_setmouse(&lines - 3, 1)
+  call feedkeys("\<LeftDrag>", 'xt')
+  call assert_equal(3, &cmdheight)
+
+  call test_setmouse(&lines - 3, 1)
+  call feedkeys("\<LeftMouse>", 'xt')
+  call test_setmouse(&lines - 1, 1)
+  call feedkeys("\<LeftDrag>", 'xt')
+  call assert_equal(1, &cmdheight)
+
+  let &mouse = save_mouse
+  set laststatus&
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 1ac4560295051fb3bfc3ac6e6a19524c449a98b3..40b81d1f3a9f7a76c1d5e1884797cc82f1ad20e5 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4984,
 /**/
     4983,
 /**/