Skip to content

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

Merged
PathGao merged 1 commit into
sftwrdotdev:masterfrom
PathGao:fix/toc-editor-source-position
Aug 2, 2026
Merged

Fix duplicate-heading ToC jumps in the editor#335
PathGao merged 1 commit into
sftwrdotdev:masterfrom
PathGao:fix/toc-editor-source-position

Conversation

@PathGao

@PathGao PathGao commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

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

PathGao commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator 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.

@PathGao
PathGao force-pushed the fix/toc-editor-source-position branch from 01ceedb to 93cf159 Compare August 2, 2026 06:38
@PathGao
PathGao marked this pull request as ready for review August 2, 2026 06:38
@PathGao
PathGao merged commit e8d60ad into sftwrdotdev:master Aug 2, 2026
5 checks passed
@PathGao
PathGao deleted the fix/toc-editor-source-position branch August 2, 2026 08:22
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