Skip to content

Commit

Permalink
fix: double callback in mutator
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Apr 4, 2023
1 parent f28e634 commit 0046508
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lua/oil/mutator/preview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,17 @@ M.show = vim.schedule_wrap(function(actions, should_confirm, cb)
cancel = make_callback(false)
confirm = make_callback(true)
vim.api.nvim_create_autocmd("BufLeave", {
callback = cancel,
callback = function()
cancel()
end,
once = true,
nested = true,
buffer = bufnr,
})
vim.api.nvim_create_autocmd("WinLeave", {
callback = cancel,
callback = function()
cancel()
end,
once = true,
nested = true,
})
Expand All @@ -157,10 +161,16 @@ M.show = vim.schedule_wrap(function(actions, should_confirm, cb)
})
)
for _, cancel_key in ipairs({ "q", "C", "c", "<C-c>", "<Esc>" }) do
vim.keymap.set("n", cancel_key, cancel, { buffer = bufnr, nowait = true })
vim.keymap.set("n", cancel_key, function()
cancel()
end, { buffer = bufnr, nowait = true })
end
vim.keymap.set("n", "O", confirm, { buffer = bufnr })
vim.keymap.set("n", "o", confirm, { buffer = bufnr })
vim.keymap.set("n", "O", function()
confirm()
end, { buffer = bufnr })
vim.keymap.set("n", "o", function()
confirm()
end, { buffer = bufnr })
end)

return M

0 comments on commit 0046508

Please sign in to comment.