preview.nvim/lua/preview
Barrett Ruth 54ef0c3c99
fix(compiler): guard active entry before clearing in process callback (#22)
* fix(compiler): guard active entry before clearing in process callback

Problem: when M.compile() is called while a previous process is still
running, the old process's vim.schedule_wrap callback unconditionally
sets active[bufnr] = nil, wiping the new process from the tracking
table. status() incorrectly returns idle and stop() becomes a no-op
against the still-running process.

Solution: capture obj as an upvalue in each callback and only clear
active[bufnr] if it still points to the same process object.

* fix(compiler): hoist obj declaration before vim.system closure

Problem: lua-language-server flagged obj as an undefined global in
both vim.schedule_wrap callbacks because local obj = vim.system(...)
puts the variable out of scope inside the closure at declaration time.
At runtime the guard active[bufnr].obj == obj evaluated obj as nil,
so the clear was always skipped and the process remained tracked
indefinitely.

Solution: split into local obj / obj = vim.system(...) so the
upvalue is in scope when the closure is defined.
2026-03-04 00:17:10 -05:00
..
commands.lua feat: unified reload field for live-preview (SSE + long-running watch) (#19) 2026-03-03 16:41:47 -05:00
compiler.lua fix(compiler): guard active entry before clearing in process callback (#22) 2026-03-04 00:17:10 -05:00
diagnostic.lua fix(presets): correct error parsers for real compiler output (#11) 2026-03-03 14:14:59 -05:00
health.lua feat: rename watch → toggle, auto-compile on start, built-in opener 2026-03-02 23:37:44 -05:00
init.lua feat: unified reload field for live-preview (SSE + long-running watch) (#19) 2026-03-03 16:41:47 -05:00
log.lua feat: rename 2026-03-02 21:23:40 -05:00
presets.lua feat: unified reload field for live-preview (SSE + long-running watch) (#19) 2026-03-03 16:41:47 -05:00
reload.lua fix(reload): bind SSE server to port 0 for OS-assigned port (#21) 2026-03-03 17:46:04 -05:00