fix(compiler): preserve viewer_open and fire PreviewWatchingStopped event#61
Merged
barrettruth merged 3 commits intomainfrom Mar 15, 2026
Merged
fix(compiler): preserve viewer_open and fire PreviewWatchingStopped event#61barrettruth merged 3 commits intomainfrom
viewer_open and fire PreviewWatchingStopped event#61barrettruth merged 3 commits intomainfrom
Conversation
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`.
Problem: there was no way for user config to react when preview watching stops, e.g. to clean up forward-search state for SyncTeX. Solution: fire a `PreviewWatchingStopped` user autocmd from `stop_watching` with `bufnr` and `provider` in the event data.
Problem: the new `PreviewWatchingStopped` event was undocumented, and the SyncTeX recipes never cleared `synctex_pdf` on watch stop. Solution: add the event to the events section and update the shared SyncTeX setup block to clear `synctex_pdf[bufnr]` on stop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
openis a fire-and-forget command (e.g.sioyek --instance-name), the spawned process exits immediately. The exit callback clearedviewer_open, causing every recompile to reopen the viewer and breaking toggle-off. Additionally, there was no user event for reacting to watch stop, making it impossible to clean up external state like SyncTeX forward-search entries.Solution
Stop resetting
viewer_openin thedo_openexit callback — it now persists untilstop_watching. Fire a newPreviewWatchingStoppeduser autocmd fromstop_watchingwithbufnrandproviderin the event data.