aboutsummaryrefslogtreecommitdiff
path: root/test/functional/autocmd/winscrolled_spec.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-11-20 08:38:46 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-11-20 21:11:37 +0800
commit035d41ac5e5fcbb49eb64b72a924c4d6f89f0579 (patch)
tree4f461e40c21bfe0e3ec488f91c55d599b317681d /test/functional/autocmd/winscrolled_spec.lua
parent822eabc5e123bca71ba945467c3b01110bb0e003 (diff)
downloadrneovim-035d41ac5e5fcbb49eb64b72a924c4d6f89f0579.tar.gz
rneovim-035d41ac5e5fcbb49eb64b72a924c4d6f89f0579.tar.bz2
rneovim-035d41ac5e5fcbb49eb64b72a924c4d6f89f0579.zip
vim-patch:partial:9.0.0913: only change in current window triggers the WinScrolled event
Problem: Only a change in the current window triggers the WinScrolled event. Solution: Trigger WinScrolled if any window scrolled or changed size. (issue vim/vim#11576) https://github.com/vim/vim/commit/0a60f79fd0c328b47b36279a95282e9f8d9e7512 Skip locking of window layout and E1312. Copy the latest version of all WinScrolled tests from Vim. Note: patch 9.0.0915 is needed for the Lua tests to pass. Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'test/functional/autocmd/winscrolled_spec.lua')
-rw-r--r--test/functional/autocmd/winscrolled_spec.lua47
1 files changed, 40 insertions, 7 deletions
diff --git a/test/functional/autocmd/winscrolled_spec.lua b/test/functional/autocmd/winscrolled_spec.lua
index 12b8e7c42d..6db2d53bbf 100644
--- a/test/functional/autocmd/winscrolled_spec.lua
+++ b/test/functional/autocmd/winscrolled_spec.lua
@@ -1,8 +1,10 @@
local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
+local exec = helpers.exec
local command = helpers.command
local feed = helpers.feed
local meths = helpers.meths
@@ -89,11 +91,42 @@ describe('WinScrolled', function()
end)
end)
-it('closing window in WinScrolled does not cause use-after-free #13265', function()
- local lines = {'aaa', 'bbb'}
- meths.buf_set_lines(0, 0, -1, true, lines)
- command('vsplit')
- command('autocmd WinScrolled * close')
- feed('<C-E>')
- assert_alive()
+describe('WinScrolled', function()
+ -- oldtest: Test_WinScrolled_mouse()
+ it('is triggered by mouse scrolling in another window', function()
+ local screen = Screen.new(75, 10)
+ screen:attach()
+ exec([[
+ set nowrap scrolloff=0
+ set mouse=a
+ call setline(1, ['foo']->repeat(32))
+ split
+ let g:scrolled = 0
+ au WinScrolled * let g:scrolled += 1
+ ]])
+
+ -- With the upper split focused, send a scroll-down event to the unfocused one.
+ meths.input_mouse('wheel', 'down', '', 0, 6, 0)
+ eq(1, eval('g:scrolled'))
+
+ -- Again, but this time while we're in insert mode.
+ feed('i')
+ meths.input_mouse('wheel', 'down', '', 0, 6, 0)
+ feed('<Esc>')
+ eq(2, eval('g:scrolled'))
+ end)
+
+ -- oldtest: Test_WinScrolled_close_curwin()
+ it('closing window does not cause use-after-free #13265', function()
+ exec([[
+ set nowrap scrolloff=0
+ call setline(1, ['aaa', 'bbb'])
+ vsplit
+ au WinScrolled * close
+ ]])
+
+ -- This was using freed memory
+ feed('<C-E>')
+ assert_alive()
+ end)
end)