From e03f51ca040882171a6bed5302eaa84ebe4936a5 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Wed, 4 Mar 2026 15:48:13 -0500 Subject: [PATCH] ci: format --- lua/preview/compiler.lua | 42 ++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/lua/preview/compiler.lua b/lua/preview/compiler.lua index f92419d..c5a81c2 100644 --- a/lua/preview/compiler.lua +++ b/lua/preview/compiler.lua @@ -208,26 +208,30 @@ function M.compile(bufnr, name, provider, ctx, opts) local watcher = vim.uv.new_fs_event() if watcher then open_watchers[bufnr] = watcher - watcher:start(out_dir, {}, vim.schedule_wrap(function(err, filename, _events) - if err or vim.fn.fnamemodify(filename or '', ':t') ~= out_name then - return - end - if opened[bufnr] then + watcher:start( + out_dir, + {}, + vim.schedule_wrap(function(err, filename, _events) + if err or vim.fn.fnamemodify(filename or '', ':t') ~= out_name then + return + end + if opened[bufnr] then + stop_open_watcher(bufnr) + return + end + if not vim.api.nvim_buf_is_valid(bufnr) then + stop_open_watcher(bufnr) + return + end + local new_stat = vim.uv.fs_stat(output_file) + if not (new_stat and new_stat.mtime.sec > pre_mtime) then + return + end stop_open_watcher(bufnr) - return - end - if not vim.api.nvim_buf_is_valid(bufnr) then - stop_open_watcher(bufnr) - return - end - local new_stat = vim.uv.fs_stat(output_file) - if not (new_stat and new_stat.mtime.sec > pre_mtime) then - return - end - stop_open_watcher(bufnr) - do_open(bufnr, output_file, provider.open) - opened[bufnr] = true - end)) + do_open(bufnr, output_file, provider.open) + opened[bufnr] = true + end) + ) end end