fix: another case of incorrect alternate buffers (#60)
This commit is contained in:
parent
4152810907
commit
b36ba91b7a
3 changed files with 30 additions and 0 deletions
|
|
@ -405,6 +405,7 @@ M.select = function(opts)
|
|||
vertical = opts.vertical,
|
||||
horizontal = opts.horizontal,
|
||||
split = opts.split,
|
||||
keepalt = true,
|
||||
}
|
||||
if vim.tbl_isempty(mods) then
|
||||
mods = nil
|
||||
|
|
|
|||
|
|
@ -102,11 +102,16 @@ M.rename_buffer = function(src_bufnr, dest_buf_name)
|
|||
-- rename logic. The only reason we can't use nvim_buf_set_name on files is because vim will
|
||||
-- think that the new buffer conflicts with the file next time it tries to save.
|
||||
if not vim.loop.fs_stat(dest_buf_name) then
|
||||
local altbuf = vim.fn.bufnr("#")
|
||||
-- This will fail if the dest buf name already exists
|
||||
local ok = pcall(vim.api.nvim_buf_set_name, src_bufnr, dest_buf_name)
|
||||
if ok then
|
||||
-- Renaming the buffer creates a new buffer with the old name. Find it and delete it.
|
||||
vim.api.nvim_buf_delete(vim.fn.bufadd(bufname), {})
|
||||
if altbuf and vim.api.nvim_buf_is_valid(altbuf) then
|
||||
vim.fn.setreg("#", altbuf)
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue