Skip to content

markdown: fix scroll sync regressions introduced in #287050#307763

Open
AshtonYoon wants to merge 1 commit intomicrosoft:mainfrom
AshtonYoon:fix/markdown-preview-scroll-sync-regressions
Open

markdown: fix scroll sync regressions introduced in #287050#307763
AshtonYoon wants to merge 1 commit intomicrosoft:mainfrom
AshtonYoon:fix/markdown-preview-scroll-sync-regressions

Conversation

@AshtonYoon
Copy link
Copy Markdown
Contributor

@AshtonYoon AshtonYoon commented Apr 4, 2026

Fixes #307762

Bug 1: Editor jumps when scrolling the preview (preview.ts)

The merge retained this.#isScrolling = false inside the early-return guard of scrollTo(), which the original PR intentionally removed. This resets the timer on the first call, letting subsequent editor scroll events re-trigger forward sync while reverse sync is still in progress.

 if (this.#isScrolling) {
-    this.#isScrolling = false;
     return;
 }

Bug 2: Preview → editor sync requires editor to be scrolled first (index.ts)

The PR switched onUpdateView to a timer-based reset but left initialization and resize handlers still using scrollDisabledCount += 1 with no timer. Since the scroll handler no longer decrements, scrollDisabledCount stays at 1 after page load and blocks all preview-to-editor sync.

Fix: apply the same timer-reset pattern (200ms) to all four remaining increment sites.

Two regressions from the merge of microsoft#287050:

1. preview.ts: The merge retained `this.#isScrolling = false` inside
   the early-return guard of `scrollTo()`, which was intentionally
   removed in the original PR. This resets the timer-based flag on
   the very first forward-sync call, allowing subsequent editor scroll
   events to re-trigger forward sync while reverse sync is in
   progress, causing the editor to jump back up.

2. index.ts: The PR converted `onUpdateView` from a decrement-counter
   to a timer-based approach but left initialization and resize
   handlers still using `scrollDisabledCount += 1` without a
   corresponding timer reset. The old scroll handler decremented the
   counter naturally; the new handler only returns early. As a result,
   after page load `scrollDisabledCount` stays at 1 indefinitely,
   blocking all preview-to-editor sync until the user scrolls the
   editor once.

Fixes:
- Remove the erroneous `this.#isScrolling = false` from scrollTo()
- Apply the same timer-reset pattern (200ms) to initialization and
  resize handlers so scrollDisabledCount is always auto-cleared

Fixes microsoft#307762
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.

Markdown preview scroll sync broken after #287050 merged to main

2 participants