fix(lsp): check if the buffer is a directory before w! it (#22289)

This commit is contained in:
Eduard Baturin
2023-02-18 09:43:59 +03:00
committed by GitHub
parent 44da6a56ba
commit f43fa301c1
2 changed files with 33 additions and 3 deletions

View File

@@ -759,9 +759,11 @@ function M.rename(old_fname, new_fname, opts)
vim.fn.bufload(oldbuf)
-- The there may be pending changes in the buffer
api.nvim_buf_call(oldbuf, function()
vim.cmd('w!')
end)
if vim.fn.isdirectory(old_fname) == 0 then
api.nvim_buf_call(oldbuf, function()
vim.cmd('w!')
end)
end
local ok, err = os.rename(old_fname, new_fname)
assert(ok, err)