fix: empty buffer placeholder and checkbox pattern fixes (#82)

* fix(buffer): use `default_category` config for empty placeholder

Problem: The empty-buffer fallback hardcoded the category name `TODO`,
ignoring the user's `default_category` config value (default: `Todo`).

Solution: Read `config.get().default_category` at render time and use
that value for both the header line and `LineMeta` category field.

* fix(diff): match optional checkbox char in `parse_buffer` patterns

Problem: `parse_buffer` used `%[.%]` which requires exactly one
character between brackets, failing to parse empty `[]` checkboxes.

Solution: Change to `%[.?%]` so the character is optional, matching
`[]`, `[ ]`, `[x]`, and `[!]` uniformly.
This commit is contained in:
Barrett Ruth 2026-03-06 12:07:52 -05:00 committed by GitHub
parent 55e83644b3
commit 7ad27f6fca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View file

@ -303,6 +303,12 @@ function M.render(bufnr)
lines, line_meta = views.category_view(tasks)
end
if #lines == 0 and #_filter_predicates == 0 then
local default_cat = config.get().default_category
lines = { '# ' .. default_cat }
line_meta = { { type = 'header', category = default_cat } }
end
if #_filter_predicates > 0 then
table.insert(lines, 1, 'FILTER: ' .. table.concat(_filter_predicates, ' '))
table.insert(line_meta, 1, { type = 'filter' })

View file

@ -33,14 +33,14 @@ function M.parse_buffer(lines)
for i = start, #lines do
local line = lines[i]
local id, body = line:match('^/(%d+)/(- %[.%] .*)$')
local id, body = line:match('^/(%d+)/(- %[.?%] .*)$')
if not id then
body = line:match('^(- %[.%] .*)$')
body = line:match('^(- %[.?%] .*)$')
end
if line == '' then
table.insert(result, { type = 'blank', lnum = i })
elseif id or body then
local stripped = body:match('^- %[.%] (.*)$') or body
local stripped = body:match('^- %[.?%] (.*)$') or body
local state_char = body:match('^- %[(.-)%]') or ' '
local priority = state_char == '!' and 1 or 0
local status = state_char == 'x' and 'done' or 'pending'