fix: prevent E565 error when opening directories with nvim . (#608)
This commit is contained in:
parent
302bbaceea
commit
685cdb4ffa
1 changed files with 4 additions and 2 deletions
|
|
@ -174,8 +174,10 @@ M.rename_buffer = function(src_bufnr, dest_buf_name)
|
||||||
-- This will fail if the dest buf name already exists
|
-- This will fail if the dest buf name already exists
|
||||||
local ok = pcall(vim.api.nvim_buf_set_name, src_bufnr, dest_buf_name)
|
local ok = pcall(vim.api.nvim_buf_set_name, src_bufnr, dest_buf_name)
|
||||||
if ok then
|
if ok then
|
||||||
-- Renaming the buffer creates a new buffer with the old name. Find it and delete it.
|
-- Renaming the buffer creates a new buffer with the old name.
|
||||||
vim.api.nvim_buf_delete(vim.fn.bufadd(bufname), {})
|
-- Find it and try to delete it, but don't if the buffer is in a context
|
||||||
|
-- where Neovim doesn't allow buffer modifications.
|
||||||
|
pcall(vim.api.nvim_buf_delete, vim.fn.bufadd(bufname), {})
|
||||||
if altbuf and vim.api.nvim_buf_is_valid(altbuf) then
|
if altbuf and vim.api.nvim_buf_is_valid(altbuf) then
|
||||||
vim.fn.setreg("#", altbuf)
|
vim.fn.setreg("#", altbuf)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue