From 00465089cb4fdf2c9fb491cd63e36ca135ac6291 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Tue, 4 Apr 2023 13:50:36 -0700 Subject: [PATCH] fix: double callback in mutator --- lua/oil/mutator/preview.lua | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lua/oil/mutator/preview.lua b/lua/oil/mutator/preview.lua index 7380c26..f84e8c2 100644 --- a/lua/oil/mutator/preview.lua +++ b/lua/oil/mutator/preview.lua @@ -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, }) @@ -157,10 +161,16 @@ M.show = vim.schedule_wrap(function(actions, should_confirm, cb) }) ) for _, cancel_key in ipairs({ "q", "C", "c", "", "" }) 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