feat(filter): oil-like editable filter line (#43)

* feat(filter): oil-like editable filter line with predicate dispatch

Problem: no way to narrow the pending buffer to a subset of tasks
without manual scrolling; filtered-out tasks would be silently deleted
on :w because diff.apply() marks unseen IDs as deleted.

Solution: add a FILTER: line rendered at the top of the buffer when a
filter is active. The line is editable — :w re-parses it and updates
the hidden set. diff.apply() gains a hidden_ids param that prevents
filtered-out tasks from being marked deleted. Predicates: cat:X,
overdue, today, priority (space-separated AND). :Pending filter sets
it programmatically; :Pending filter clear removes it.

* ci: format
This commit is contained in:
Barrett Ruth 2026-02-26 18:29:56 -05:00 committed by GitHub
parent 3da23c924a
commit dcb6a4781d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 526 additions and 8 deletions

View file

@ -27,8 +27,13 @@ end
function M.parse_buffer(lines)
local result = {}
local current_category = nil
local start = 1
if lines[1] and lines[1]:match('^FILTER:') then
start = 2
end
for i, line in ipairs(lines) do
for i = start, #lines do
local line = lines[i]
local id, body = line:match('^/(%d+)/(- %[.%] .*)$')
if not id then
body = line:match('^(- %[.%] .*)$')
@ -65,8 +70,9 @@ function M.parse_buffer(lines)
end
---@param lines string[]
---@param hidden_ids? table<integer, true>
---@return nil
function M.apply(lines)
function M.apply(lines, hidden_ids)
local parsed = M.parse_buffer(lines)
local now = timestamp()
local data = store.data()
@ -160,7 +166,7 @@ function M.apply(lines)
end
for id, task in pairs(old_by_id) do
if not seen_ids[id] then
if not seen_ids[id] and not (hidden_ids and hidden_ids[id]) then
task.status = 'deleted'
task['end'] = now
task.modified = now