feat: most moves and copies will copy the undofile (#583)

This commit is contained in:
Steven Arcangeli 2025-02-13 09:40:01 -08:00
parent 5313690956
commit 32dd3e378d
4 changed files with 51 additions and 6 deletions

View file

@ -195,6 +195,18 @@ M.rename_buffer = function(src_bufnr, dest_buf_name)
-- Try to delete, but don't if the buffer has changes
pcall(vim.api.nvim_buf_delete, src_bufnr, {})
end
-- Renaming a buffer won't load the undo file, so we need to do that manually
if vim.bo[dest_bufnr].undofile then
vim.api.nvim_buf_call(dest_bufnr, function()
vim.cmd.rundo({
args = { vim.fn.undofile(dest_buf_name) },
magic = { file = false, bar = false },
mods = {
emsg_silent = true,
},
})
end)
end
end)
return true
end