Skip to content

Markdown preview scroll sync broken after #287050 merged to main #307762

@AshtonYoon

Description

@AshtonYoon

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:

  1. Open a markdown file + preview side-by-side
  2. Scroll the preview → editor does not follow
  3. 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions