Skip to content

codemirror jumpToHash and ctrl + click link following don't work when multiple headings have the same text #13892

@bwat47

Description

@bwat47

Operating system

Windows

Joplin version

3.5.9

Desktop version info

Joplin 3.5.9 (dev, win32)

Device: win32, AMD Ryzen 7 5800X3D 8-Core Processor
Client ID: a170c40dd1cb4c77b2517337fefdbbf0
Sync Version: 3
Profile Version: 49
Keychain Supported: Yes
Alternative instance ID: -

Revision: 364bdd9 (dev)

Backup: 1.4.3
Codeblock Autocomplete: 1.0.2
Context Utils: 1.2.0
Copy as HTML: 1.5.0
Diff view: 0.3.1
Draw.io: 2.2.0
Heading Navigator: 0.5.2
Journal: 2.0.0
Kity Minder: 1.0.16
Markmap: 1.7.0
Note Tabs: 1.4.0
Outline: 1.5.15
Paste as Markdown: 1.1.8
Quick Note: 1.1.2
Simple Image Resize: 1.5.15

Current behaviour

Steps to re-create

1. Put the attached markdown into a note: test.md

2. In a plugin, try using editor.execCommand to call jumpToHash to scroll the note to heading-2

You'll see that the the heading isn't found

3. Or, try using the built-in ctrl + click follow link function, and you'll see the below error:

Image

Expected behaviour

Should scroll to the second heading

Notes:

This works as expected in:

  • The markdown viewer
  • The TinyMCE editor
  • The proseMirror editor in the web app

The proseMirror version of jumpToHash does handle tracking duplicate headings (as mentioned in this PR: #12949 (comment)), but the codeMirror version does not:

https://github.com/laurent22/joplin/blob/dev/packages/editor/ProseMirror/utils/jumpToHash.ts
https://github.com/laurent22/joplin/blob/dev/packages/editor/CodeMirror/editorCommands/jumpToHash.ts

A potential fix is to update the codemirror jumpToHash function and the findLineMatchingLink (used by the ctrl + click link following) to use similar logic to track duplicate headings: dev...bwat47:joplin:combined_hash_fix

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIt's a bug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions