From 39b54fbc50f11d7fcf0d058d666f4305bc57fd01 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Fri, 6 Mar 2026 11:35:45 -0500 Subject: [PATCH] feat(init): allow `:Pending done` with no args to use cursor line Problem: `:Pending done` required an explicit task ID, making it awkward to mark the current task done while inside the pending buffer. Solution: When called with no ID, `M.done()` reads the cursor row from `buffer.meta()` to resolve the task ID, erroring if the cursor is not on a saved task line. --- lua/pending/init.lua | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/lua/pending/init.lua b/lua/pending/init.lua index a10d72d..06c722c 100644 --- a/lua/pending/init.lua +++ b/lua/pending/init.lua @@ -430,13 +430,28 @@ function M.toggle_complete() end end ----@param id_str string +---@param id_str? string ---@return nil function M.done(id_str) - local id = tonumber(id_str) - if not id then - log.error('Invalid task ID: ' .. tostring(id_str)) - return + local id + if not id_str or id_str == '' then + local row = vim.api.nvim_win_get_cursor(0)[1] + local meta = buffer.meta() + if not meta[row] or meta[row].type ~= 'task' then + log.error('Cursor is not on a task line.') + return + end + id = meta[row].id + if not id then + log.error('Task has no ID — save the buffer first.') + return + end + else + id = tonumber(id_str) + if not id then + log.error('Invalid task ID: ' .. tostring(id_str)) + return + end end local s = get_store() s:load()