obsidian-tasks icon indicating copy to clipboard operation
obsidian-tasks copied to clipboard

If there are duplicate headings with the same name in a file, backlinks for tasks in those headings always go to tasks in first heading

Open liangzh-404 opened this issue 2 years ago • 12 comments

Expected Behavior

A

  • [ ] test A

A

  • [ ] test B
filename includes 2022-09-16
group by heading

I should see the real link to test B but right now what I see is the first one image

Current behaviour

A

  • [ ] test A

A

  • [ ] test B
filename includes 2022-09-16
group by heading
image

Steps to reproduce

A

  • [ ] test A

A

  • [ ] test B
filename includes 2022-09-16
group by heading
image

Which Operating Systems are you using?

  • [ ] Android
  • [ ] iPhone/iPad
  • [ ] Linux
  • [X] macOS
  • [ ] Windows

Obsidian Version

0.16.2

Tasks Plugin Version

1.13.1

Checks

  • [ ] I have tried it with all other plugins disabled and the error still occurs

Possible solution

No response

liangzh-404 avatar Sep 16 '22 10:09 liangzh-404

I am sorry, I cannot tell from the pictures what the problem is - and all the pictures look the same to me.

Please can you provide some descriptive text of what the situation is, and what the problem is?

claremacrae avatar Sep 16 '22 20:09 claremacrae

Also, the "steps to reproduce" do not include any instructions as to what to do to reproduce the problem. Please include actual steps to follow. Thank you!

claremacrae avatar Sep 16 '22 22:09 claremacrae

I've diffed the 3 sections of the report, and all 3 images are identical, they use the same URL.

claremacrae avatar Sep 19 '22 19:09 claremacrae

@liangzh-404 Are these the steps to reproduce?

  1. Create a file with 2022-09-16 in the name
  2. Paste the following text in to it:
## A
- [ ] test A

## A
- [ ] test B

## Search
```tasks
filename includes 2022-09-16
group by heading
```
  1. View the file in Live Preview or Reading mode.4.

    You will see something like: image

  2. Click on the backlink for 'test B'

Expected behaviour: It should jump to the second section called A, which contains 'task B'. Actual behaviour: it jumps to the first section called A, which contains 'task A'.

claremacrae avatar Sep 19 '22 19:09 claremacrae

If so, this has nothing to do with the group by instruction.

The reason for this behaviour is that the backlink is made by combining:

  • the file name containing the task
  • the heading name containing the task

In other words, the backlink jumps to the section rather than to the line. As far as I know, there is no way to jump to an exact line inside Obsidian.

So if you have two sections with the same name a file, Obsidian always jumps to the first of those sections.

claremacrae avatar Sep 19 '22 19:09 claremacrae

As far as I know, there is no way to jump to an exact line inside Obsidian.

Not to an exact line, but to an exact block, and tasks are actually blocks.

However, this requires that the task has a block ID appended, which could be done either by the user manually, or by Obsidian automatically. If this has not been suggested before, we could make feature requests out of this:

  1. If a block ID exists for the task, let the backlink point to the exact task block instead of the heading,
  2. Add an option to create block IDs for tasks automatically upon creation of the task, so that Obsidian can link to them. The automatic block ID could be something nice like ^task-3 for the 3rd task that has been created in the same file (I think block IDs must be unique per file) instead of al cryptic hash.
  3. Now that I think of it, maybe we could also consider the existence of a block ID with that given format as indicator that this is a task, instead of using the global task tag for that purpose.

@claremacrae do you know if this is already discussed somewhere? Shall I create a new issue/discussion for this?

Cito avatar Sep 20 '22 08:09 Cito

@claremacrae do you know if this is already discussed somewhere? Shall I create a new issue/discussion for this?

Good points - thank you! Leave it with me, I'll break it down in to tasks and add them, and link from here...

claremacrae avatar Sep 20 '22 09:09 claremacrae

Comment moved to https://github.com/obsidian-tasks-group/obsidian-tasks/discussions/1162#discussioncomment-3690301

claremacrae avatar Sep 20 '22 12:09 claremacrae

@claremacrae Did you mean your last comment to go into another discussion? I do not see how it applies here.

Cito avatar Sep 20 '22 12:09 Cito

@Cito Yes moved, thanks. (There are a lot of GitHub notifications from you in my email - for which I am very grateful!!)

claremacrae avatar Sep 20 '22 13:09 claremacrae

Good points - thank you! Leave it with me, I'll break it down in to tasks and add them, and link from here...

I have added these ideas, which will go some way towards fixing the issues discussed here:

https://github.com/obsidian-tasks-group/obsidian-tasks/discussions/1165

Backlinks for tasks with block IDs should link straight to the task's line

https://github.com/obsidian-tasks-group/obsidian-tasks/discussions/1166

Make backlinks use multiple headings to distinguish between sections with the same name

Those will improve the current behaviour.

I have a feeling that there is a discussion somewhere about auto-adding block IDs to tasks, but I can't find it.

claremacrae avatar Sep 20 '22 21:09 claremacrae

The original description was 'group by cannot properly render exact heading' - I have renamed it to describe the issue.

claremacrae avatar Sep 20 '22 21:09 claremacrae

It needs testing, but this should have been fixed in Tasks release 3.4.0, as backlinks now go to the exact line, not the heading,.

claremacrae avatar Jul 14 '23 19:07 claremacrae

It needs testing, but this should have been fixed in Tasks release 3.4.0, as backlinks now go to the exact line, not the heading,.

Confirmed. The backlinks now go to the correct line, so duplicate headings no longer matter.

claremacrae avatar Aug 11 '23 19:08 claremacrae