Skip to content

Commit 96392af

Browse files
[BREAKING CHANGE] Update parsing plan dates. Run ":TSUpdate org" to get latest changes.
1 parent 9cf968e commit 96392af

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

lua/orgmode/parser/section.lua

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,29 @@ function Section.from_node(section_node, file, parent)
8888

8989
for child in section_node:iter_children() do
9090
if child:type() == 'plan' then
91-
for _, plan_date in ipairs(ts_utils.get_named_children(child)) do
92-
local type = plan_date:type():upper()
93-
local node = plan_date:child(0)
94-
if type == 'TIMESTAMP' then
95-
type = 'NONE'
96-
node = plan_date
91+
local plan_children = ts_utils.get_named_children(child)
92+
local len = #plan_children
93+
local i = 1
94+
while i <= len do
95+
local plan_item = plan_children[i]
96+
if not plan_item then
97+
break
98+
end
99+
local next_item = plan_children[i + 1]
100+
101+
local type = 'NONE'
102+
local node = plan_item
103+
local item_type = plan_item:type():upper()
104+
105+
if item_type == 'NAME' and next_item and next_item:type():upper() == 'TIMESTAMP' then
106+
local t = file:get_node_text(plan_item):upper()
107+
if t == 'DEADLINE:' or t == 'SCHEDULED:' or t == 'CLOSED:' then
108+
node = next_item
109+
type = t:sub(1, t:len() - 1)
110+
i = i + 1
111+
end
97112
end
113+
98114
local date = file:get_node_text(node)
99115
utils.concat(
100116
data.dates,
@@ -103,6 +119,7 @@ function Section.from_node(section_node, file, parent)
103119
range = Range.from_node(node),
104120
})
105121
)
122+
i = i + 1
106123
end
107124
end
108125
if child:type() == 'body' then

0 commit comments

Comments
 (0)