fix: errors when writing files over ssh (#159)
This commit is contained in:
parent
9509ae0fee
commit
bfa0e8705e
1 changed files with 5 additions and 4 deletions
|
|
@ -391,16 +391,17 @@ M.write_file = function(bufnr)
|
|||
vim.loop.fs_close(fd)
|
||||
end
|
||||
vim.cmd.doautocmd({ args = { "BufWritePre", bufname }, mods = { silent = true } })
|
||||
vim.cmd.write({ args = { tmpfile }, bang = true, mods = { silent = true } })
|
||||
vim.cmd.write({ args = { tmpfile }, bang = true, mods = { silent = true, noautocmd = true } })
|
||||
local tmp_bufnr = vim.fn.bufadd(tmpfile)
|
||||
|
||||
shell.run({ "scp", "-C", tmpfile, scp_url }, function(err)
|
||||
vim.bo[bufnr].modifiable = true
|
||||
if err then
|
||||
vim.notify(string.format("Error writing file: %s", err), vim.log.levels.ERROR)
|
||||
else
|
||||
vim.bo[bufnr].modified = false
|
||||
vim.cmd.doautocmd({ args = { "BufWritePost", bufname }, mods = { silent = true } })
|
||||
end
|
||||
vim.bo[bufnr].modifiable = true
|
||||
vim.bo[bufnr].modified = false
|
||||
vim.cmd.doautocmd({ args = { "BufWritePost", bufname }, mods = { silent = true } })
|
||||
vim.loop.fs_unlink(tmpfile)
|
||||
vim.api.nvim_buf_delete(tmp_bufnr, { force = true })
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue