1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 17:30:04 +08:00

fix(autosave): use pcall to avoid error

This commit is contained in:
wsdjeg 2022-09-28 00:05:13 +08:00
parent e7cb486364
commit c494645e0b

View File

@ -56,7 +56,7 @@ local function save_buffer(bufnr)
vim.fn.filewritable(vim.fn.bufname(bufnr)) == 1 and
vim.fn.empty(vim.fn.bufname(bufnr)) == 0 then
local lines = vim.fn.getbufline(bufnr, 1, '$')
vim.fn.writefile(lines, location_path(vim.fn.bufname(bufnr)))
pcall(vim.fn.writefile, {lines, location_path(vim.fn.bufname(bufnr))})
if vim.fn.empty(default_opt.backupdir) == 1 then
vim.fn.setbufvar(bufnr, '&modified', 0)
vim.cmd('silent checktime ' .. bufnr)