From ca61db712731b50bb5af331e7629209da230becf Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Thu, 5 Mar 2026 11:18:46 -0500 Subject: [PATCH] fix(init): edit recompute, filter predicates, sync action listing Problem: `M.edit()` skipped `_recompute_counts()` after saving, `compute_hidden_ids` lacked `done`/`pending` predicates, and `run_sync` defaulted to `sync` instead of listing available actions. Solution: Replace `s:save()` with `_save_and_notify()` in `M.edit()`, add `done` and `pending` filter predicates, and list backend actions when no action is specified. --- lua/pending/init.lua | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/lua/pending/init.lua b/lua/pending/init.lua index f4f7264..983c9bf 100644 --- a/lua/pending/init.lua +++ b/lua/pending/init.lua @@ -142,6 +142,16 @@ local function compute_hidden_ids(tasks, predicates) visible = false break end + elseif pred == 'done' then + if task.status ~= 'done' then + visible = false + break + end + elseif pred == 'pending' then + if task.status ~= 'pending' then + visible = false + break + end end end if not visible then @@ -536,12 +546,25 @@ end ---@param action? string ---@return nil local function run_sync(backend_name, action) - action = (action and action ~= '') and action or 'sync' local ok, backend = pcall(require, 'pending.sync.' .. backend_name) if not ok then vim.notify('Unknown sync backend: ' .. backend_name, vim.log.levels.ERROR) return end + if not action or action == '' then + local actions = {} + for k, v in pairs(backend) do + if type(v) == 'function' and k:sub(1, 1) ~= '_' then + table.insert(actions, k) + end + end + table.sort(actions) + vim.notify( + backend_name .. ' actions: ' .. table.concat(actions, ', '), + vim.log.levels.INFO + ) + return + end if type(backend[action]) ~= 'function' then vim.notify(backend_name .. " backend has no '" .. action .. "' action", vim.log.levels.ERROR) return @@ -804,7 +827,7 @@ function M.edit(id_str, rest) s:update(id, updates) - s:save() + _save_and_notify() local bufnr = buffer.bufnr() if bufnr and vim.api.nvim_buf_is_valid(bufnr) then @@ -841,7 +864,7 @@ function M.command(args) local id_str, edit_rest = rest:match('^(%S+)%s*(.*)') M.edit(id_str, edit_rest) elseif SYNC_BACKEND_SET[cmd] then - local action = rest:match('^(%S+)') or 'sync' + local action = rest:match('^(%S+)') run_sync(cmd, action) elseif cmd == 'archive' then local d = rest ~= '' and tonumber(rest) or nil