ebullient/obsidian-task-collector

Task delete after collection (when no new line)

Closed this issue · 7 comments

MDsza commented

After activating the "Collect tasks" command the last added task will be deleted in the ordered task list, but only when this task has no "new line" / enter sign at the end.

Just to be clear, what you're saying is that, given this list:

1. [ ] Task in ordered list
2. [x] Task in ordered list

line 2 will be deleted entirely (not moved/collected?)

A specific text example helps.

MDsza commented

No, sorry to clarify: it does not matter, if the task is checked or not; only when a last line with a task does not have a "enter" / "new line" at the end, then it will be deleted after collection.

[ ] Task and checked one WITHOUT a newline character or a carriage return character = regex \n or \r?) will be deleted after collection
[ ] Taskand checked one WITH a new line will not be deleted after collection

Hope this is clear now.

Can you give me a raw text snippet I can use?

I have a few cases here where there are no line endings, and it doesn't happen there:

https://github.com/ebullient/obsidian-task-collector/blob/main/test/moveCompletedItem.test.ts

MDsza commented

I tested some different text snippet, like this one:

1 - ToDos

  • 1
  • 2
  • 3

2 - Later >

9 - Done √

  • aa
  • bb
  • cc

Important: last line "cc" has to be without any further signs.

1 - ToDos

  • aa
  • bb
  • 1
  • 2
  • 3

2 - Later >

9 - Done √

...with the last line missing / deleted.

Hope this helps.

MDsza commented

This issue was closed by @ebullient today; that means it is solved? Would interest me, what caused this problem (because I collect all my daily tasks during the day when they come in my mind in an INBOX-Note and it would be crucial for me to use the task collector if there could some of this tasks be deleted, without knowing it.

Yes.. I discovered the issue and fixed it (note the commit reference). I also cut a release containing the fix (1.0.12).

You would only encounter this bug if you use Task Collector in a certain way. If your use of an inbox note always has a new line at the end of the task, you're safe. For example, I have shortcuts that add tasks to my inbox, but those always end with a newline (so the next append is on the next line), which means this bug doesn't occur.

All of that said, I agree, losing tasks is super bad! I've added a test for this case to ensure it doesn't occur again (tests for task collection are here: https://github.com/ebullient/obsidian-task-collector/blob/main/test/moveCompletedItem.test.ts). If you see any gaps in that data (for patterns you need), I'm happy to have a PR to add a test for it! (sample starting text, and what you would expect to see as a result, including custom section configuration you think is important).

MDsza commented

@ebullient : thank you so much for your time and efforts you put into investigating this special issue (yes, my "Append Task"-Plugin in Raycast does NOT add an new line at the end) and solving it so quickly. I just installed and tested your new version and now all works fine! Great.