fix(compiler): add fs_stat check to one-shot open path
Problem: the long-running process path already guarded opens with vim.uv.fs_stat(), but the one-shot compile path and M.open() did not. Compilation can exit 0 and produce no output, and output files can be externally deleted between compile and open. Solution: add the same fs_stat guard to the one-shot open branch and to M.open() before attempting to launch the viewer.
This commit is contained in:
parent
bc22350692
commit
1456b3070a
1 changed files with 5 additions and 1 deletions
|
|
@ -230,7 +230,7 @@ function M.compile(bufnr, name, provider, ctx, opts)
|
|||
r.inject(output_file)
|
||||
r.broadcast()
|
||||
end
|
||||
if provider.open and not opened[bufnr] and output_file ~= '' then
|
||||
if provider.open and not opened[bufnr] and output_file ~= '' and vim.uv.fs_stat(output_file) then
|
||||
if provider.open == true then
|
||||
vim.ui.open(output_file)
|
||||
elseif type(provider.open) == 'table' then
|
||||
|
|
@ -452,6 +452,10 @@ function M.open(bufnr, open_config)
|
|||
log.dbg('no last output file for buffer %d', bufnr)
|
||||
return false
|
||||
end
|
||||
if not vim.uv.fs_stat(output) then
|
||||
log.dbg('output file no longer exists for buffer %d: %s', bufnr, output)
|
||||
return false
|
||||
end
|
||||
if type(open_config) == 'table' then
|
||||
local open_cmd = vim.list_extend({}, open_config)
|
||||
table.insert(open_cmd, output)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue