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:
parent
3da23c924a
commit
dcb6a4781d
7 changed files with 526 additions and 8 deletions
|
|
@ -164,10 +164,34 @@ end, {
|
|||
bar = true,
|
||||
nargs = '*',
|
||||
complete = function(arg_lead, cmd_line)
|
||||
local subcmds = { 'add', 'archive', 'due', 'edit', 'sync', 'undo' }
|
||||
local subcmds = { 'add', 'archive', 'due', 'edit', 'filter', 'sync', 'undo' }
|
||||
if not cmd_line:match('^Pending%s+%S') then
|
||||
return filter_candidates(arg_lead, subcmds)
|
||||
end
|
||||
if cmd_line:match('^Pending%s+filter') then
|
||||
local after_filter = cmd_line:match('^Pending%s+filter%s+(.*)') or ''
|
||||
local used = {}
|
||||
for word in after_filter:gmatch('%S+') do
|
||||
used[word] = true
|
||||
end
|
||||
local candidates = { 'clear', 'overdue', 'today', 'priority' }
|
||||
local store = require('pending.store')
|
||||
store.load()
|
||||
local seen = {}
|
||||
for _, task in ipairs(store.active_tasks()) do
|
||||
if task.category and not seen[task.category] then
|
||||
seen[task.category] = true
|
||||
table.insert(candidates, 'cat:' .. task.category)
|
||||
end
|
||||
end
|
||||
local filtered = {}
|
||||
for _, c in ipairs(candidates) do
|
||||
if not used[c] and (arg_lead == '' or c:find(arg_lead, 1, true) == 1) then
|
||||
table.insert(filtered, c)
|
||||
end
|
||||
end
|
||||
return filtered
|
||||
end
|
||||
if cmd_line:match('^Pending%s+edit') then
|
||||
return complete_edit(arg_lead, cmd_line)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue