@@ -43,43 +43,43 @@ export function getTasksFromFileContent2(
4343 let sectionIndex = 0 ;
4444 const line2ListItem : Map < number , ListItem > = new Map ( ) ;
4545 for ( const listItem of listItems ) {
46- if ( listItem . task !== undefined ) {
47- const lineNumber = listItem . position . start . line ;
48- if ( lineNumber >= linesInFile ) {
49- /*
50- Obsidian CachedMetadata has told us that there is a task on lineNumber, but there are
51- not that many lines in the file.
52-
53- This was the underlying cause of all the 'Stuck on "Loading Tasks..."' messages,
54- as it resulted in the line 'undefined' being parsed.
55-
56- Somehow the file had been shortened whilst Obsidian was closed, meaning that
57- when Obsidian started up, it got the new file content, but still had the old cached
58- data about locations of list items in the file.
59- */
60- logger . debug (
61- `${ filePath } Obsidian gave us a line number ${ lineNumber } past the end of the file. ${ linesInFile } .` ,
62- ) ;
63- return tasks ;
64- }
65- if ( currentSection === null || currentSection . position . end . line < lineNumber ) {
66- // We went past the current section (or this is the first task).
67- // Find the section that is relevant for this task and the following of the same section.
68- currentSection = Cache . getSection ( lineNumber , fileCache . sections ) ;
69- sectionIndex = 0 ;
70- }
46+ const lineNumber = listItem . position . start . line ;
47+ if ( lineNumber >= linesInFile ) {
48+ /*
49+ Obsidian CachedMetadata has told us that there is a task on lineNumber, but there are
50+ not that many lines in the file.
51+
52+ This was the underlying cause of all the 'Stuck on "Loading Tasks..."' messages,
53+ as it resulted in the line 'undefined' being parsed.
54+
55+ Somehow the file had been shortened whilst Obsidian was closed, meaning that
56+ when Obsidian started up, it got the new file content, but still had the old cached
57+ data about locations of list items in the file.
58+ */
59+ logger . debug (
60+ `${ filePath } Obsidian gave us a line number ${ lineNumber } past the end of the file. ${ linesInFile } .` ,
61+ ) ;
62+ return tasks ;
63+ }
64+ if ( currentSection === null || currentSection . position . end . line < lineNumber ) {
65+ // We went past the current section (or this is the first task).
66+ // Find the section that is relevant for this task and the following of the same section.
67+ currentSection = Cache . getSection ( lineNumber , fileCache . sections ) ;
68+ sectionIndex = 0 ;
69+ }
7170
72- if ( currentSection === null ) {
73- // Cannot process a task without a section.
74- continue ;
75- }
71+ if ( currentSection === null ) {
72+ // Cannot process a task without a section.
73+ continue ;
74+ }
7675
77- const line = fileLines [ lineNumber ] ;
78- if ( line === undefined ) {
79- logger . debug ( `${ filePath } : line ${ lineNumber } - ignoring 'undefined' line.` ) ;
80- continue ;
81- }
76+ const line = fileLines [ lineNumber ] ;
77+ if ( line === undefined ) {
78+ logger . debug ( `${ filePath } : line ${ lineNumber } - ignoring 'undefined' line.` ) ;
79+ continue ;
80+ }
8281
82+ if ( listItem . task !== undefined ) {
8383 let task ;
8484 try {
8585 task = Task . fromLine ( {
0 commit comments