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:
Thomas Vigouroux
2020-08-31 09:53:10 +02:00
committed by GitHub
parent c2662210b5
commit 24b5f69a49
2 changed files with 20 additions and 1 deletions

View File

@@ -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)