Skip to content

Commit 50e8ec7

Browse files
phanenibhagwan
authored andcommitted
fix: ignore ModeChanged event in zz
1 parent 8337813 commit 50e8ec7

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

lua/fzf-lua/utils.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ function M.line_count(win, buf)
11331133
end
11341134
end
11351135

1136-
function M.zz()
1136+
local function _zz()
11371137
-- skip for terminal buffers
11381138
if M.is_term_buffer() then return end
11391139
local lnum1 = vim.api.nvim_win_get_cursor(0)[1]
@@ -1155,6 +1155,10 @@ function M.zz()
11551155
end
11561156
end
11571157

1158+
function M.zz()
1159+
M.eventignore(_zz, "ModeChanged")
1160+
end
1161+
11581162
---@param context vim.context.mods
11591163
---@param func function
11601164
---@return ... any
@@ -1171,9 +1175,10 @@ end
11711175
function M.eventignore(func, scope)
11721176
local save_ei = vim.o.eventignore
11731177
vim.o.eventignore = scope or "all"
1174-
local ret = { func() }
1178+
local ret = { pcall(func) }
11751179
vim.o.eventignore = save_ei
1176-
return unpack(ret)
1180+
if not ret[1] then error(ret[2]) end
1181+
return select(2, unpack(ret))
11771182
end
11781183

11791184
-- Set buffer for window without an autocmd

0 commit comments

Comments
 (0)