preview.nvim/spec
Barrett Ruth d1fd2b2a73
refactor(compiler): replace 7 state tables with unified BufState (#52)
* refactor(compiler): replace 7 state tables with unified `BufState`

Problem: `compiler.lua` tracked per-buffer state across 7 separate
module-level tables, causing scattered cleanup, triplicated
error-handling blocks, accumulating `BufUnload` autocmds on every
compile, and a race condition where `active[bufnr]` (cleared
asynchronously on process exit) was used as the toggle on/off gate.

Solution: Consolidate all per-buffer state into a single `state` table
holding a `preview.BufState` record per buffer. Extract `handle_errors`
and `clear_errors` helpers. Move `BufUnload` lifecycle entirely into
`M.toggle` with `unload_autocmd` tracking to prevent accumulation.
Toggle now gates on `s.watching` (synchronous boolean) and reopens a
closed viewer when watching is active rather than stopping.

* fix(compiler): split nil guard in `M.stop` for type narrowing

* ci: typing
2026-03-05 23:58:19 -05:00
..
commands_spec.lua fix: lifecycle cleanup and defensive runtime checks (#29) 2026-03-04 14:02:16 -05:00
compiler_spec.lua refactor(compiler): replace 7 state tables with unified BufState (#52) 2026-03-05 23:58:19 -05:00
diagnostic_spec.lua feat: rename 2026-03-02 21:23:40 -05:00
helpers.lua feat: rename watch → toggle, auto-compile on start, built-in opener 2026-03-02 23:37:44 -05:00
init_spec.lua fix: lifecycle cleanup and defensive runtime checks (#29) 2026-03-04 14:02:16 -05:00
minimal_init.lua ci: format 2026-03-01 17:22:59 -05:00
presets_spec.lua fix: quickfix support for long-running providers (#41) 2026-03-04 17:23:06 -05:00
reload_spec.lua fix(ci): resolve lua-language-server warnings (#32) 2026-03-04 14:28:52 -05:00