fix: block autocommands when setting preview buffer (#2010)

Telescope creates most floating windows with `noautocmd = true`, so
these windows do not trigger autocommands, but preview buffer is set in
window using `nvim_win_set_buf()`, which triggers buffer autocommands.
This may be unwanted, so block them using 'eventignore'.
This commit is contained in:
zeertzjq
2022-06-15 16:43:10 +08:00
committed by GitHub
parent f33df8f35f
commit d96eaa914a
3 changed files with 12 additions and 5 deletions

View File

@@ -410,6 +410,13 @@ function utils.get_os_command_output(cmd, cwd)
return stdout, ret, stderr
end
function utils.win_set_buf_noautocmd(win, buf)
local save_ei = vim.o.eventignore
vim.o.eventignore = "all"
vim.api.nvim_win_set_buf(win, buf)
vim.o.eventignore = save_ei
end
local load_once = function(f)
local resolved = nil
return function(...)