If you have a note setup like the following, the plugin crashes:
# h1
### h3
- [x] task
# h1
As far as I can tell, it's because it's jumping from an h1 to an h3. If I make that second header an h2, the plugin runs fine. I think there's an issue with how the plugin finds parent headers/sections, or it's an issue with how the plugin calculates the internal level value.
In buildTree, as it steps through flatSections, context.level is 3 and section.level is 1. Then, stepsUpToParent is 3. When this is passed to getNthAncestor, that function returns a parent that doesn't exist.
VM628:260 Uncaught (in promise) TypeError: Cannot read property 'append' of undefined
at SectionParser.buildTree (eval at <anonymous> (app.js:1), <anonymous>:260:21)
at SectionParser.parse (eval at <anonymous> (app.js:1), <anonymous>:226:14)
at Archiver.archiveTasksToSameFile (eval at <anonymous> (app.js:1), <anonymous>:286:43)
at ObsidianTaskArchiver.eval (eval at <anonymous> (app.js:1), <anonymous>:469:48)
at Generator.next (<anonymous>)
at fulfilled (eval at <anonymous> (app.js:1), <anonymous>:28:58)
If you have a note setup like the following, the plugin crashes:
As far as I can tell, it's because it's jumping from an
h1
to anh3
. If I make that second header anh2
, the plugin runs fine. I think there's an issue with how the plugin finds parent headers/sections, or it's an issue with how the plugin calculates the internallevel
value.https://github.com/ivan-lednev/obsidian-task-archiver/blob/f06d7bc5a5d5e201f3fd383c8eb89b3b4f26aa3b/src/parser/SectionParser.ts#L59
In
buildTree
, as it steps throughflatSections
,context.level
is 3 andsection.level
is 1. Then,stepsUpToParent
is 3. When this is passed togetNthAncestor
, that function returns a parent that doesn't exist.