-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Markdown preview scroll sync broken after #287050 merged to main #307762
Description
A problem occurred where #287050 did not work properly after being merged into main.
Bug 1: Editor jumps when scrolling the preview
File: src/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-based flag on the first call, allowing subsequent editor scroll events to re-trigger forward sync during reverse sync — causing the editor to jump.
if (this.#isScrolling) {
- this.#isScrolling = false; // ← should have been removed
return;
}Bug 2: Preview → editor sync doesn't work until editor is scrolled once
File: preview-src/index.ts
The PR switched onUpdateView to a timer-based reset (scrollDisabledCount = 0 after 50ms), but left initialization and resize handlers still using scrollDisabledCount += 1 with no timer reset. Since the scroll handler no longer decrements the counter, scrollDisabledCount stays at 1 after page load and blocks all preview-to-editor sync indefinitely.
Repro:
- Open a markdown file + preview side-by-side
- Scroll the preview → editor does not follow
- Scroll the editor once, then scroll the preview → now it works
Fix: Apply the same timer-reset pattern to initialization and resize handlers. PR to follow.