mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
fix(lsp): rename fails on missing parent directory #27291
Problem: If a rename results in a path that has missing parent directory(s), it will fail. Solution: Do a recursive mkdir before attempting the rename.
This commit is contained in:
@ -693,6 +693,9 @@ function M.rename(old_fname, new_fname, opts)
|
||||
end)
|
||||
end
|
||||
|
||||
local newdir = assert(vim.fs.dirname(new_fname))
|
||||
vim.fn.mkdir(newdir, 'p')
|
||||
|
||||
local ok, err = os.rename(old_fname, new_fname)
|
||||
assert(ok, err)
|
||||
|
||||
|
Reference in New Issue
Block a user