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:
parent
9ea049b6a0
commit
6fd24afbfa
1 changed files with 3 additions and 3 deletions
|
|
@ -33,14 +33,14 @@ function M.parse_buffer(lines)
|
||||||
|
|
||||||
for i = start, #lines do
|
for i = start, #lines do
|
||||||
local line = lines[i]
|
local line = lines[i]
|
||||||
local id, body = line:match('^/(%d+)/(- %[.%] .*)$')
|
local id, body = line:match('^/(%d+)/(- %[.?%] .*)$')
|
||||||
if not id then
|
if not id then
|
||||||
body = line:match('^(- %[.%] .*)$')
|
body = line:match('^(- %[.?%] .*)$')
|
||||||
end
|
end
|
||||||
if line == '' then
|
if line == '' then
|
||||||
table.insert(result, { type = 'blank', lnum = i })
|
table.insert(result, { type = 'blank', lnum = i })
|
||||||
elseif id or body then
|
elseif id or body then
|
||||||
local stripped = body:match('^- %[.%] (.*)$') or body
|
local stripped = body:match('^- %[.?%] (.*)$') or body
|
||||||
local state_char = body:match('^- %[(.-)%]') or ' '
|
local state_char = body:match('^- %[(.-)%]') or ' '
|
||||||
local priority = state_char == '!' and 1 or 0
|
local priority = state_char == '!' and 1 or 0
|
||||||
local status = state_char == 'x' and 'done' or 'pending'
|
local status = state_char == 'x' and 'done' or 'pending'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue