Skip to content

Commit

Permalink
fix: Use pcall in noautocmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Isrothy committed Oct 5, 2024
1 parent 19201c7 commit 1ebe37f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lua/neominimap/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,20 @@ M.is_search_mode = function()
end
return false
end

--- @generic F: function
--- @param f F
--- @return F
M.noautocmd = function(f)
function M.noautocmd(f)
return function(...)
local eventignore = vim.o.eventignore
vim.o.eventignore = "all"
local r = { f(...) }
local r = { pcall(f, ...) }
vim.o.eventignore = eventignore
return unpack(r)
if not r[1] then
error(r[2])
end
return unpack(r, 2, table.maxn(r))
end
end

Expand Down

0 comments on commit 1ebe37f

Please sign in to comment.