mirror of
https://github.com/neovim/neovim.git
synced 2025-09-23 11:38:31 +00:00
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)
0a60f79fd0
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>
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user