fix(lsp): create missing directory before creating file (#19835)

Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
This commit is contained in:
shaunsingh
2022-09-24 06:46:21 -04:00
committed by GitHub
parent 24b5449b3d
commit caf5738fa9
2 changed files with 20 additions and 1 deletions

View File

@@ -1977,6 +1977,22 @@ describe('LSP', function()
exec_lua('vim.lsp.util.apply_workspace_edit(...)', edit, 'utf-16')
eq(true, exec_lua('return vim.loop.fs_stat(...) ~= nil', tmpfile))
end)
it('Supports file creation in folder that needs to be created with CreateFile payload', function()
local tmpfile = helpers.tmpname()
os.remove(tmpfile) -- Should not exist, only interested in a tmpname
tmpfile = tmpfile .. '/dummy/x/'
local uri = exec_lua('return vim.uri_from_fname(...)', tmpfile)
local edit = {
documentChanges = {
{
kind = 'create',
uri = uri,
},
}
}
exec_lua('vim.lsp.util.apply_workspace_edit(...)', edit, 'utf-16')
eq(true, exec_lua('return vim.loop.fs_stat(...) ~= nil', tmpfile))
end)
it('createFile does not touch file if it exists and ignoreIfExists is set', function()
local tmpfile = helpers.tmpname()
write_file(tmpfile, 'Dummy content')