fix: make sure preview buffer is valid before writing to it (#376)

This commit is contained in:
Alvaro Muñoz
2021-01-01 20:42:36 +01:00
committed by GitHub
parent a0b37473a9
commit f15af583eb

View File

@@ -35,6 +35,7 @@ utils.job_maker = function(cmd, bufnr, opts)
args = cmd, args = cmd,
env = opts.env, env = opts.env,
on_exit = vim.schedule_wrap(function(j) on_exit = vim.schedule_wrap(function(j)
if not vim.api.nvim_buf_is_valid(bufnr) then return end
if opts.mode == "append" then if opts.mode == "append" then
local count = vim.api.nvim_buf_line_count(bufnr) local count = vim.api.nvim_buf_line_count(bufnr)
vim.api.nvim_buf_set_lines(bufnr, count, -1, false, j:result()) vim.api.nvim_buf_set_lines(bufnr, count, -1, false, j:result())