obsidian-tasks: When a block-referenced task is made complete, it is completed after rewriting the contents of another task.
Expected Behavior
When a block-referenced task is made complete, the correct task is completed.
Current Behavior
When a block-referenced task is made complete, it is completed after rewriting the contents of another task.
Steps to Reproduce
Complete task2 referenced by ref task2 with Live Preview of the following Markdown
## Category1
- [ ] task1
## Category 2
- [ ] task2 ^ca47c7
---
- ref task2 ![[#^ca47c7]]
-
before

-
after

Context (Environment)
- Obsidian version: 0.14.13
- Tasks version: 1.5.1
- I have tried it with all other plugins disabled and the error still occurs
Possible Solution
No idea.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 27 (3 by maintainers)
Commits related to this issue
- test: Add a test which is marked as failing for #688 — committed to claremacrae/obsidian-tasks by claremacrae a year ago
- test: Add a test for #688, based on mock data saved from Obsidian. — committed to obsidian-tasks-group/obsidian-tasks by claremacrae a year ago
- fix: If task only appears once in file, use that line number. This fixes #688, in the usual case where the embedded task only appears once in the file. It also fixes #1680, again so long as the task... — committed to obsidian-tasks-group/obsidian-tasks by claremacrae a year ago
working on solving this right now and I admit I’m having a little bit of fun 😄
https://user-images.githubusercontent.com/38915815/218335057-c0a9daeb-c1a4-4e88-840b-25be3fb2c89c.mov
Hi @BluBloos, thanks very much for all your efforts on this. I am really happy to be guided by your recommendations.
I do agree that documenting the issue would be OK too.
Thanks very much for investigating this!
I feel the solution to this is the issue elsewhere about not overwriting a task line whose content differs from the task being completed…
Then, at least the user’s data will not be corrupted.
The other solution is to document an example carefully and log an issue in the Forum. Doing so well enough to get the issue implemented takes several hours of effort in my experience.
As schemar mentioned in a previous comment,
I’m afraid there may indeed be a shortcoming in what Ob API is offering us.
To summarize the issue:
InlineRendererclass acts on some generated HTML from some .md. This rendering applies when in “Reading” mode or in an inline markdown block.![[noteName]],![[#someHeader]], and![[^foo]].InlineRendererloops through all list items in the HTML to create a list of tasks (Task[]). The sectionStart for each Task comes direct from a call to myMarkdownPostProcessorContext.getSectionInfo(taskHTMLelem).replaceTaskWithTaskssees this section information and replaces our toggled task into the very first task in the source file.![[noteName]]work OK since the inline markdown block begins at the beginning of the source note.![[#someHeader]]and![[^foo]].Without adjustments to the Ob API (unless someone can ideate a workaround), I suggest it be documented as a “known issue” …
At first I thought it was a rare occurrence too, but I have confirmed that it is reproducible, so I am reporting it. I’m glad to be able to contribute to obsidian-tasks, as I make the most use of it among the obsidian plugins.