]> granicus.if.org Git - vim/commitdiff
patch 8.2.4803: WinScrolled not always triggered when scrolling with mouse v8.2.4803
authorLemonBoy <thatlemon@gmail.com>
Thu, 21 Apr 2022 21:52:11 +0000 (22:52 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 21 Apr 2022 21:52:11 +0000 (22:52 +0100)
Problem:    WinScrolled not always triggered when scrolling with the mouse.
Solution:   Add calls to may_trigger_winscrolled(). (closes #10246)

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

index 42963341c574ab4c48fa8a7e32bc9f3d3aa780a2..a0c5156052bcb89dae102931b461bb1b4199ffc3 100644 (file)
@@ -1127,6 +1127,7 @@ ins_mousescroll(int dir)
        }
 #endif
        did_scroll = TRUE;
+       may_trigger_winscrolled();
     }
 
     curwin->w_redr_status = TRUE;
@@ -2087,6 +2088,7 @@ nv_mousescroll(cmdarg_T *cap)
     if (curwin != old_curwin && curwin->w_p_cul)
        redraw_for_cursorline(curwin);
 # endif
+    may_trigger_winscrolled();
 
     curwin->w_redr_status = TRUE;
 
index c4ba10fcb56a655190aebfdbf28aad1f9336658a..466b6ec2e4d5eb22a3697d21df8afd98467b147c 100644 (file)
@@ -364,6 +364,37 @@ func Test_WinScrolled()
   call delete('Xtest_winscrolled')
 endfunc
 
+func Test_WinScrolled_mouse()
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+    set nowrap scrolloff=0
+    set mouse=a term=xterm ttymouse=sgr mousetime=200 clipboard=
+    call setline(1, ['foo']->repeat(32))
+    split
+    let g:scrolled = 0
+    au WinScrolled * let g:scrolled += 1
+  END
+  call writefile(lines, 'Xtest_winscrolled_mouse')
+  let buf = RunVimInTerminal('-S Xtest_winscrolled_mouse', {'rows': 10})
+
+  " With the upper split focused, send a scroll-down event to the unfocused one.
+  call test_setmouse(7, 1)
+  call term_sendkeys(buf, "\<ScrollWheelDown>")
+  call TermWait(buf)
+  call term_sendkeys(buf, ":echo g:scrolled\<CR>")
+  call WaitForAssert({-> assert_match('^1', term_getline(buf, 10))}, 1000)
+
+  " Again, but this time while we're in insert mode.
+  call term_sendkeys(buf, "i\<ScrollWheelDown>\<Esc>")
+  call TermWait(buf)
+  call term_sendkeys(buf, ":echo g:scrolled\<CR>")
+  call WaitForAssert({-> assert_match('^2', term_getline(buf, 10))}, 1000)
+
+  call StopVimInTerminal(buf)
+  call delete('Xtest_winscrolled_mouse')
+endfunc
+
 func Test_WinScrolled_close_curwin()
   CheckRunVimInTerminal
 
@@ -1572,7 +1603,7 @@ func Test_QuitPre()
   " Close the other window, <afile> should be correct.
   exe win_id2win(winid) . 'q'
   call assert_equal('Xfoo', g:afile)
+
   unlet g:afile
   bwipe Xfoo
   bwipe Xbar
index 5ed7e76edd5c89cee3f1d391e03c4fb23d73ce13..e4e297e034481b938829dd43d28ff2d51f25ca1c 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4803,
 /**/
     4802,
 /**/