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

This commit is contained in:
glepnir committed 2023-09-19 18:44:48 +08:00
1 parent 71530cc972
commit 437ed3cee2
2 files changed
+26

No files matched your search

+3
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");
+23
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