fix(compiler): preserve viewer_open when viewer process exits

Problem: when `open` is a custom command like `sioyek --instance-name`,
the process exits immediately after delegating to the running instance.
The exit callback reset `viewer_open`, causing every recompile to reopen
the viewer and toggle to reopen instead of stopping.

Solution: stop clearing `viewer_open` in the `do_open` exit callback.
The flag now persists for the watch session and is only reset by
`stop_watching`.
This commit is contained in:
Barrett Ruth 2026-03-15 13:34:39 -04:00
parent f185ae78f7
commit 08f0b037e0
Signed by: barrett
GPG key ID: A6C96C9349D2FC81

View file

@ -135,9 +135,8 @@ local function do_open(bufnr, output_file, open_config)
vim.schedule_wrap(function() vim.schedule_wrap(function()
local s = state[bufnr] local s = state[bufnr]
if s and s.viewer == proc then if s and s.viewer == proc then
log.dbg('viewer exited for buffer %d, resetting viewer_open', bufnr) log.dbg('viewer exited for buffer %d', bufnr)
s.viewer = nil s.viewer = nil
s.viewer_open = nil
else else
log.dbg('viewer exited for buffer %d (stale proc, ignoring)', bufnr) log.dbg('viewer exited for buffer %d (stale proc, ignoring)', bufnr)
end end