Skip to content

Commit fcf100c

Browse files
authored
fix(E242): wrapping aucmds in vim.defer_fn
on opening/closing windows on aucmds regarding Win*-Events and any event involving some other window being opened/closed right there, vim chokes with E242, saying eg.: cannot open window while closing another
1 parent 6c60d17 commit fcf100c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lua/qf.lua

+9-3
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,9 @@ function qf.setup_autocmds(config)
845845

846846
au("WinClosed", function()
847847
if vim.o.ft ~= "ft" then
848-
vim.cmd("lclose")
848+
vim.defer_fn(function()
849+
vim.cmd("lclose")
850+
end, 50)
849851
end
850852
end)
851853

@@ -866,13 +868,17 @@ function qf.setup_autocmds(config)
866868

867869
if list.focus_open then
868870
au("WinEnter", function()
869-
open(k, true, true)
871+
vim.defer_fn(function()
872+
open(k, true, true)
873+
end, 50)
870874
end)
871875
end
872876

873877
if list.auto_open then
874878
au("QuickFixCmdPost", function()
875-
open(k, true, true)
879+
vim.defer_fn(function()
880+
open(k, true, true)
881+
end, 50)
876882
end, { pattern = list_post_commands(k) })
877883
end
878884
end

0 commit comments

Comments
 (0)