fix(compiler): check output exists before opening from long-running process (#24)
* fix(compiler): check output exists before opening from long-running process Problem: for long-running processes (typst watch), M.compile() calls the opener immediately after vim.system() returns, before the process has produced any output. On first run the output file does not exist yet, so the opener is called on a nonexistent path. Solution: guard the open block with vim.uv.fs_stat so it only fires if the output file already exists at spawn time. * style(compiler): reformat long condition for stylua
This commit is contained in:
parent
54ef0c3c99
commit
da3e3e4249
1 changed files with 6 additions and 1 deletions
|
|
@ -147,7 +147,12 @@ function M.compile(bufnr, name, provider, ctx)
|
|||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue