mirror of
https://github.com/neovim/neovim.git
synced 2025-12-07 23:22:39 +00:00
fix(win): ignore closing wins in win_findbuf #12798
This caused segfaults when calling win_findbuf in an `on_detach` callback, when the callback was triggered when closing the last window containing the buffer.
This commit is contained in:
@@ -216,4 +216,23 @@ describe('lua: buffer event callbacks', function()
|
||||
eq(1, meths.get_var('listener_cursor_line'))
|
||||
end)
|
||||
|
||||
it('does not SEGFAULT when calling win_findbuf in on_detach', function()
|
||||
|
||||
exec_lua[[
|
||||
local buf = vim.api.nvim_create_buf(false, false)
|
||||
|
||||
vim.cmd"split"
|
||||
vim.api.nvim_win_set_buf(0, buf)
|
||||
|
||||
vim.api.nvim_buf_attach(buf, false, {
|
||||
on_detach = function(_, buf)
|
||||
vim.fn.win_findbuf(buf)
|
||||
end
|
||||
})
|
||||
]]
|
||||
|
||||
command("q!")
|
||||
helpers.assert_alive()
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user