markdown: fix scroll sync regressions introduced in #287050#307763
Open
AshtonYoon wants to merge 1 commit intomicrosoft:mainfrom
Open
markdown: fix scroll sync regressions introduced in #287050#307763AshtonYoon wants to merge 1 commit intomicrosoft:mainfrom
AshtonYoon wants to merge 1 commit intomicrosoft:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #307762
Bug 1: Editor jumps when scrolling the preview (
preview.ts)The merge retained
this.#isScrolling = falseinside the early-return guard ofscrollTo(), 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
onUpdateViewto a timer-based reset but left initialization and resize handlers still usingscrollDisabledCount += 1with no timer. Since the scroll handler no longer decrements,scrollDisabledCountstays at1after page load and blocks all preview-to-editor sync.Fix: apply the same timer-reset pattern (200ms) to all four remaining increment sites.