Skip to content

[mac] Fix preview outline navigation (#260)#275

Merged
Shpigford merged 1 commit into
mainfrom
outline-anchor-mismatch
Apr 27, 2026
Merged

[mac] Fix preview outline navigation (#260)#275
Shpigford merged 1 commit into
mainfrom
outline-anchor-mismatch

Conversation

@Shpigford

Copy link
Copy Markdown
Owner

Summary

  • Outline clicks in preview now do a 3-tier scroll lookup (exact line+col → line-only → closest-by-line text match with anchor-link stripped), so the outline always finds a sensible target even when the regex parser and cmark-gfm disagree.
  • Skip the editor's showFindIndicator when the editor isn't the visible pane — fixes the yellow rectangle that was bleeding through SwiftUI's opacity-0 layer onto the preview.
  • Adds a brief in-preview flash on the matched heading text that mirrors the edit-mode find indicator (bright yellow mark wrapping just the text, ~1.3s fade).

Fixes #260

Test plan

  • Preview mode: click outline entries — preview scrolls and the heading text flashes yellow; no stray rectangle on a different line.
  • Edit mode: outline click still scrolls + shows the find indicator on the heading line.
  • Doc with two headings sharing the same text — clicking each in the outline lands on the corresponding instance.
  • Doc with a heading whose data-sourcepos column doesn't match Swift's column 1 (e.g. 1–3 leading spaces) — tier 2 line-only match takes over.
  • Heading with double-quotes in the title — JSON-escaped injection doesn't break the JS.

…hlight bleed

Outline clicks in preview mode were scrolling to the wrong heading (or
landing nowhere) and showing a yellow find-indicator pulse over the hidden
editor that bled through SwiftUI's opacity-0 layer.

- scrollToHeading now does 3-tier fallback (exact line:col match on
  data-sourcepos, then line-only, then closest-by-line text-content match
  with anchor-link stripped) so the outline always finds a sensible target
  even when the regex parser and cmark-gfm disagree about which lines are
  headings.
- Skip scrollToRange (which fires showFindIndicator) when the editor is
  not the visible pane — eliminates the yellow rectangle bleed-through.
- Add a brief in-preview flash on the matched heading text, parallel to
  the edit-mode find indicator: bright yellow mark wrapping just the
  heading text (excluding the hover anchor link), fades out over ~1.3s.

Fixes #260
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying clearly with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9260638
Status: ✅  Deploy successful!
Preview URL: https://778b5d04.clearly-cjz.pages.dev
Branch Preview URL: https://outline-anchor-mismatch.clearly-cjz.pages.dev

View logs

@Shpigford
Shpigford merged commit 816d790 into main Apr 27, 2026
4 checks passed
@Shpigford
Shpigford deleted the outline-anchor-mismatch branch April 27, 2026 19:09
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.

Preview outline navigation scrolls to the incorrect anchor

1 participant