fix(compiler): skip reload command for one-shot builds
Problem: compile() unconditionally resolved the reload command, so
:Preview build on a provider with reload = function/table (e.g. typst)
would start a long-running process (typst watch) instead of a one-shot
compile (typst compile). Error diagnostics were also lost because
typst watch does not exit non-zero on input errors.
Solution: add an opts parameter to compile() with a oneshot flag.
M.build() passes { oneshot = true } so resolve_reload_cmd() is
skipped and the one-shot path is always taken. toggle() continues
to call compile() without the flag, preserving long-running behavior
for watch mode.
This commit is contained in:
parent
da3e3e4249
commit
c556ea9ea1
2 changed files with 8 additions and 3 deletions
|
|
@ -55,7 +55,9 @@ end
|
|||
---@param name string
|
||||
---@param provider preview.ProviderConfig
|
||||
---@param ctx preview.Context
|
||||
function M.compile(bufnr, name, provider, ctx)
|
||||
function M.compile(bufnr, name, provider, ctx, opts)
|
||||
opts = opts or {}
|
||||
|
||||
if vim.bo[bufnr].modified then
|
||||
vim.cmd('silent! update')
|
||||
end
|
||||
|
|
@ -81,7 +83,10 @@ function M.compile(bufnr, name, provider, ctx)
|
|||
last_output[bufnr] = output_file
|
||||
end
|
||||
|
||||
local reload_cmd = resolve_reload_cmd(provider, resolved_ctx)
|
||||
local reload_cmd
|
||||
if not opts.oneshot then
|
||||
reload_cmd = resolve_reload_cmd(provider, resolved_ctx)
|
||||
end
|
||||
|
||||
if reload_cmd then
|
||||
log.dbg(
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ function M.build(bufnr)
|
|||
end
|
||||
local ctx = M.build_context(bufnr)
|
||||
local provider = config.providers[name]
|
||||
compiler.compile(bufnr, name, provider, ctx)
|
||||
compiler.compile(bufnr, name, provider, ctx, { oneshot = true })
|
||||
end
|
||||
|
||||
---@param bufnr? integer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue