refactor: move forge ref detection from parse.body() to diff

Problem: `parse.body()` stripped forge tokens from the description,
losing the raw text. This made inline overlay rendering impossible
since the token no longer existed in the buffer.

Solution: remove the `forge.parse_ref()` branch from `parse.body()`
and call `forge.find_refs()` in `diff.parse_buffer()` instead. The
description now retains forge tokens verbatim; `_extra._forge_ref`
is still populated from the first matched ref.
This commit is contained in:
Barrett Ruth 2026-03-10 18:58:24 -04:00
parent e98b5a8e4a
commit 0a64691edd
2 changed files with 5 additions and 13 deletions

View file

@ -1,4 +1,5 @@
local config = require('pending.config')
local forge = require('pending.forge')
local parse = require('pending.parse')
---@class pending.ParsedEntry
@ -56,6 +57,8 @@ function M.parse_buffer(lines)
end
local description, metadata = parse.body(stripped)
if description and description ~= '' then
local refs = forge.find_refs(description)
local forge_ref = refs[1] and refs[1].ref or nil
table.insert(result, {
type = 'task',
id = id and tonumber(id) or nil,
@ -66,7 +69,7 @@ function M.parse_buffer(lines)
due = metadata.due,
rec = metadata.rec,
rec_mode = metadata.rec_mode,
forge_ref = metadata.forge_ref,
forge_ref = forge_ref,
lnum = i,
})
end

View file

@ -6,7 +6,6 @@ local config = require('pending.config')
---@field rec? string
---@field rec_mode? 'scheduled'|'completion'
---@field priority? integer
---@field forge_ref? pending.ForgeRef
---@class pending.parse
local M = {}
@ -597,17 +596,7 @@ function M.body(text)
metadata.rec = raw_spec
i = i - 1
else
local forge = require('pending.forge')
local ref = forge.parse_ref(token)
if ref then
if metadata.forge_ref then
break
end
metadata.forge_ref = ref
i = i - 1
else
break
end
break
end
end
end