@@ -92,6 +92,20 @@ module.config.public = {
9292 -- ```
9393 create_todo_parents = false ,
9494
95+ -- Automatically update the parent todo state when a child node is updated.
96+ --
97+ -- eg:
98+ -- ```norg
99+ -- - ( ) parent
100+ -- -- ( ) child
101+ -- ```
102+ -- Marking `-- ( ) child` as done (with a keybind) will result in:
103+ -- ```norg
104+ -- - (-) parent
105+ -- -- (x) child
106+ -- ```
107+ update_todo_parents = true ,
108+
95109 -- When `true`, will automatically create a TODO extension for an item
96110 -- if it does not exist and an operation is performed on that item.
97111 --
@@ -346,6 +360,7 @@ module.private = {
346360
347361 local first_status_extension = module .private .find_first_status_extension (node :named_child (1 )) --- @diagnostic disable-line -- TODO : type error workaround <pysan3 >
348362
363+ local parent_line
349364 if not first_status_extension then
350365 if not module .config .public .create_todo_items then
351366 return
@@ -354,9 +369,10 @@ module.private = {
354369 local row , _ , _ , column = node :named_child (0 ):range () --- @diagnostic disable-line -- TODO : type error workaround <pysan3 >
355370
356371 vim .api .nvim_buf_set_text (buf , row , column , row , column , { " (" .. char .. " ) " })
357- module . private . update_parent ( buf , row , 0 )
372+ parent_line = row
358373 else
359374 local range = module .required [" core.integrations.treesitter" ].get_node_range (first_status_extension )
375+ parent_line = range .row_start
360376
361377 module .private .fire_update_event (char , range .row_start )
362378
@@ -368,7 +384,10 @@ module.private = {
368384 range .column_end ,
369385 { char }
370386 )
371- module .private .update_parent (buf , range .row_start , 0 )
387+ end
388+
389+ if module .config .public .update_todo_parents then
390+ module .private .update_parent (buf , parent_line , 0 )
372391 end
373392
374393 for child in node :iter_children () do --- @diagnostic disable-line -- TODO : type error workaround <pysan3 >
0 commit comments