feat(diff): persist forge refs in store on write
Problem: forge refs parsed from buffer lines were discarded during diff reconciliation and never stored in the JSON. Solution: thread `forge_ref` through `parse_buffer` entries into `diff.apply`, storing it in `task._extra._forge_ref` for both new and existing tasks.
This commit is contained in:
parent
3a3e5b0505
commit
253ec9664f
1 changed files with 11 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ local parse = require('pending.parse')
|
|||
---@field due? string
|
||||
---@field rec? string
|
||||
---@field rec_mode? string
|
||||
---@field forge_ref? pending.ForgeRef
|
||||
---@field lnum integer
|
||||
|
||||
---@class pending.diff
|
||||
|
|
@ -65,6 +66,7 @@ function M.parse_buffer(lines)
|
|||
due = metadata.due,
|
||||
rec = metadata.rec,
|
||||
rec_mode = metadata.rec_mode,
|
||||
forge_ref = metadata.forge_ref,
|
||||
lnum = i,
|
||||
})
|
||||
end
|
||||
|
|
@ -113,6 +115,7 @@ function M.apply(lines, s, hidden_ids)
|
|||
recur = entry.rec,
|
||||
recur_mode = entry.rec_mode,
|
||||
order = order_counter,
|
||||
_extra = entry.forge_ref and { _forge_ref = entry.forge_ref } or nil,
|
||||
})
|
||||
else
|
||||
seen_ids[entry.id] = true
|
||||
|
|
@ -147,6 +150,13 @@ function M.apply(lines, s, hidden_ids)
|
|||
changed = true
|
||||
end
|
||||
end
|
||||
if entry.forge_ref ~= nil then
|
||||
if not task._extra then
|
||||
task._extra = {}
|
||||
end
|
||||
task._extra._forge_ref = entry.forge_ref
|
||||
changed = true
|
||||
end
|
||||
if entry.status and task.status ~= entry.status then
|
||||
task.status = entry.status
|
||||
if entry.status == 'done' then
|
||||
|
|
@ -173,6 +183,7 @@ function M.apply(lines, s, hidden_ids)
|
|||
recur = entry.rec,
|
||||
recur_mode = entry.rec_mode,
|
||||
order = order_counter,
|
||||
_extra = entry.forge_ref and { _forge_ref = entry.forge_ref } or nil,
|
||||
})
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue