fix(#1989): cut/paste over open buffer (#2279)

* fix(#1989): cut/paste overwrite deletes destination buffer

* fix(#1989): cut/paste overwrite deletes destination buffer
This commit is contained in:
Alexander Courtis 2023-07-02 17:13:50 +10:00 committed by GitHub
parent d17389ce53
commit 4af572246c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -161,6 +161,17 @@ function M.get_nodes_by_line(nodes_all, line_start)
end
function M.rename_loaded_buffers(old_path, new_path)
-- delete new if it exists
for _, buf in pairs(vim.api.nvim_list_bufs()) do
if vim.api.nvim_buf_is_loaded(buf) then
local buf_name = vim.api.nvim_buf_get_name(buf)
if buf_name == new_path then
vim.api.nvim_buf_delete(buf, { force = true })
end
end
end
-- rename old to new
for _, buf in pairs(vim.api.nvim_list_bufs()) do
if vim.api.nvim_buf_is_loaded(buf) then
local buf_name = vim.api.nvim_buf_get_name(buf)