mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
fix(float): trigger winnew event when float window create
This commit is contained in:
parent
71530cc972
commit
437ed3cee2
@ -195,6 +195,9 @@ Window nvim_open_win(Buffer buffer, Boolean enter, Dict(float_config) *config, E
|
|||||||
if (win_valid(wp) && buffer > 0) {
|
if (win_valid(wp) && buffer > 0) {
|
||||||
Boolean noautocmd = !enter || fconfig.noautocmd;
|
Boolean noautocmd = !enter || fconfig.noautocmd;
|
||||||
win_set_buf(wp, buf, noautocmd, err);
|
win_set_buf(wp, buf, noautocmd, err);
|
||||||
|
if (!fconfig.noautocmd) {
|
||||||
|
apply_autocmds(EVENT_WINNEW, NULL, NULL, false, buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!win_valid(wp)) {
|
if (!win_valid(wp)) {
|
||||||
api_set_error(err, kErrorTypeException, "Window was closed immediately");
|
api_set_error(err, kErrorTypeException, "Window was closed immediately");
|
||||||
|
@ -103,6 +103,29 @@ describe('float window', function()
|
|||||||
assert_alive()
|
assert_alive()
|
||||||
end)
|
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()
|
it('opened with correct height', function()
|
||||||
local height = exec_lua([[
|
local height = exec_lua([[
|
||||||
vim.go.winheight = 20
|
vim.go.winheight = 20
|
||||||
|
Loading…
Reference in New Issue
Block a user