fix(float): trigger winnew event when float window create

This commit is contained in:
glepnir 2023-09-11 19:46:15 +08:00
parent 71530cc972
commit 437ed3cee2
2 changed files with 26 additions and 0 deletions

View File

@ -195,6 +195,9 @@ Window nvim_open_win(Buffer buffer, Boolean enter, Dict(float_config) *config, E
if (win_valid(wp) && buffer > 0) {
Boolean noautocmd = !enter || fconfig.noautocmd;
win_set_buf(wp, buf, noautocmd, err);
if (!fconfig.noautocmd) {
apply_autocmds(EVENT_WINNEW, NULL, NULL, false, buf);
}
}
if (!win_valid(wp)) {
api_set_error(err, kErrorTypeException, "Window was closed immediately");

View File

@ -103,6 +103,29 @@ describe('float window', function()
assert_alive()
end)
it('open with WinNew autocmd', function()
local res = exec_lua([[
local triggerd = false
local buf = vim.api.nvim_create_buf(true, true)
vim.api.nvim_create_autocmd('WinNew', {
callback = function(opt)
if opt.buf == buf then
triggerd = true
end
end
})
local opts = {
relative = "win",
row = 0, col = 0,
width = 1, height = 1,
noautocmd = false,
}
vim.api.nvim_open_win(buf, true, opts)
return triggerd
]])
eq(true, res)
end)
it('opened with correct height', function()
local height = exec_lua([[
vim.go.winheight = 20