-
-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When a block-referenced task is made complete, it is completed after rewriting the contents of another task. #688
Comments
Thank you for the report @0skgc! We need to investigate further, but I assume that the indexes of lists and sections are different within the reference. If that's the case, a fix would be tricky, as that is done by obsidian. |
This is brilliant @0skgc - Thank you very much indeed for reporting it. I have very occasionally seen issues similar to this, where the completed task is written in the wrong file or wrong task, over-writing and losing another task. I have been trying hard to reproduce it, when it happens, but never got a reproduction. So I assumed it was some weird timing thing. With this setup:
Then when I mark the task as complete via the |
Here is a demo: Issue.688.Repro.mov |
I don't use footnotes, but this exactly matches my experience of what has happened, but for me it's rare and when I spot it, I have never been able to reproduce it. So I am super happy there is a reproduction now! |
Oh, it's not a footnote, it's a transclusion. |
At first I thought it was a rare occurrence too, but I have confirmed that it is reproducible, so I am reporting it. |
No it's not a transclusion. I give up! |
I thought it was a transclusion. Why is it not? |
You're right! Sorry! |
I have been able to reproduce this with both these versions of Tasks:
|
Just to capture what I've done so far to investigate this, and some possible areas to look at. Display of debug info about tasksI wanted to be able to see the section and line numbers for tasks, especially those displayed at the bottom of the file. In 220cbb4 I adjusted the display of tasks to include:
Which are: /** Line number where the section starts that contains this task. */
public readonly sectionStart: number;
/** The index of the nth task in its section. */
public readonly sectionIndex: number;
public readonly path: string;
public readonly precedingHeader: string | null; It's very much experimental. It breaks the display What the results seem to show
|
There is useful information in CONTRIBUTING's 'How does Tasks handle status changes?'. I need to confirm next which of those 4 routes is used when clicking on the embedded task. Some thoughts/questions:
Lines 20 to 30 in 17c9545
Lines 138 to 145 in 17c9545
|
I've confirmed that when I click on the block-referenced task to complete it, the code invoked is the call handler in There are a few calls to const task = Task.fromLine({
line,
path,
sectionStart: 0, // We don't need this to toggle it here in the editor.
sectionIndex: 0, // We don't need this to toggle it here in the editor.
precedingHeader: null, // We don't need this to toggle it here in the editor.
}); I wonder if there any that I could adjust so that they pass in the line numbers, and then this might fix the finding of the correct task to complete. I'm going to have a break now - will leave this for a while, in case anything that I've said so far prompts any suggestions from @schemar ... |
If I recall correctly, Tasks used line numbers (instead of sections) at some point. I moved to sections in order to utilize the (then) new Obsidian API for the markdown post processor. If I remember right, it is more performant than going line-by-line. Or maybe it is more accurate. Or possibly both 😅 Adding line numbers to tasks should be easy. Would they be available for block-referenced tasks? If it was the line number from the editor, it wouldn't be the line number in the file. Potentially, this is something that should be discussed with lishid. Shouldn't Obsidian's API provide the correct section data? However, I am not sure line numbers would solve the timing issue? They would still change while the user interacts if you add more than one task. |
cc @lishid |
hi, it seems still not work right? @schemar |
@quanru Will you please stop pinging people. Nothing has changed in Tasks, so I would expect this still to be broken. Have you tested this and found it to work? If so, please add information like what version of Obsidian and Tasks you are using. |
@claremacrae Sorry! I tested this and found it still to be broken. My version information: |
Yes, that is expected. There is currently a lot of effort going in to Tasks right now, but not in this area. |
working on solving this right now and I admit I'm having a little bit of fun 😄 Screen.Recording.2023-02-12.at.3.20.34.PM.mov |
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:
Without adjustments to the Ob API (unless someone can ideate a workaround), I suggest it be documented as a "known issue" ... |
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. |
I do agree that documenting the issue would be OK too. Thanks very much for investigating this! |
One work around could be to ignore clicks if the task is within a referenced section, if it's possible to identify that. Or maybe show a warning instead of handling the task. 🤔 |
There is precedent for producing a warning. https://obsidian-tasks-group.github.io/obsidian-tasks/getting-started/#limitations-and-warnings (There have been some grumbles from users, as it is obtrusive and cannot be disabled) |
I think all three of these should be done? The first is a fix right now to ensure no data loss. The latter is to let people know about the limitation. And the middle one is the long-term solution to "resolve" the limitation. I'm hoping that in pursuit of the middle one - getting more information about the issue, will reveal some sort of workaround or in fact that the Ob API does have what is needed ...
What I meant by workaround was a different way to implement the feature (mark a task that is rendered in an inline markdown view as done) |
Hi @BluBloos, thanks very much for all your efforts on this. I am really happy to be guided by your recommendations. |
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
Context (Environment)
Possible Solution
No idea.
The text was updated successfully, but these errors were encountered: