fix: dont error if the previewer is not able to set at the current time

This commit is contained in:
TJ DeVries
2021-01-30 22:57:36 -05:00
parent b1fb172b7f
commit 4e0dfa2e70

View File

@@ -31,7 +31,8 @@ previewers.file_maker = function(filepath, bufnr, opts)
else else
path.read_file_async(filepath, vim.schedule_wrap(function(data) path.read_file_async(filepath, vim.schedule_wrap(function(data)
if not vim.api.nvim_buf_is_valid(bufnr) then return end if not vim.api.nvim_buf_is_valid(bufnr) then return end
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, vim.split(data, '[\r]?\n')) local ok = pcall(vim.api.nvim_buf_set_lines, bufnr, 0, -1, false, vim.split(data, '[\r]?\n'))
if not ok then return end
if opts.callback then opts.callback(bufnr) end if opts.callback then opts.callback(bufnr) end
putils.highlighter(bufnr, ft) putils.highlighter(bufnr, ft)