Skip to content

Fix duplicate-heading ToC jumps in the editor - #335

Draft
PathGao wants to merge 31 commits into
alecdotdev:masterfrom
PathGao:fix/toc-editor-source-position
Draft

Fix duplicate-heading ToC jumps in the editor#335
PathGao wants to merge 31 commits into
alecdotdev:masterfrom
PathGao:fix/toc-editor-source-position

Conversation

@PathGao

@PathGao PathGao commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #202.

The preview already jumps by the deduplicated heading id. The editor path still searched by heading text from line 1, so selecting a duplicate title always focused the first heading.

This change passes the clicked preview heading’s data-sourcepos start line through the ToC callback and reveals that exact Monaco line. Text matching remains only as a fallback when a source position is unavailable.

Validation:

  • npm ci
  • npm run check
  • npm test (153 passing)
  • cargo test --manifest-path src-tauri/Cargo.toml (27 passing)
  • isolated macOS release bundle: two identical headings; selecting the second ToC entry in edit mode selected line 5, the second heading.

Depends on #333. Merge after the existing linear chain.

PathGao added 30 commits July 31, 2026 11:07
@PathGao

PathGao commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

@alecdotdev This is the next linear child after #333. It addresses the reporter’s remaining #202 reproduction: preview jumps already use the deduplicated id, while editor jumps were still text searches from line 1. The editor now receives the clicked heading’s source line; a missing source position retains the text-search fallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect Jumping for Table of Contents Titles

1 participant