Skip to content

fix(editor): preserve source scroll position while editing - #710

Open
murongg wants to merge 1 commit into
v2from
fix/source-scroll-jump
Open

fix(editor): preserve source scroll position while editing#710
murongg wants to merge 1 commit into
v2from
fix/source-scroll-jump

Conversation

@murongg

@murongg murongg commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • preserve the external source-editor viewport across CodeMirror input measurements
  • only scroll after restoration when the updated cursor is actually outside the viewport
  • cover regular typing, IME composition, deletion, off-screen cursor reveal, and stale navigation snapshots

Why

Source mode delegates vertical scrolling to .paper-scroll while CodeMirror virtualizes the long document inside .cm-scroller. The first edit after selecting a visible line could trigger a delayed measurement correction and move that line to the top of the viewport.

Validation

  • pnpm --filter @markra/editor test — 40 files, 531 tests passed
  • pnpm --filter @markra/app test — 134 files, 1555 tests passed
  • pnpm --filter @markra/editor build — passed
  • pnpm --filter @markra/app build — passed
  • Browser QA with a synthetic 600-line document: typing and Backspace on a middle line both kept scrollTop at 7268.5 and the line offset at 305.6875px

Risk

  • Scoped to source mode editors that use an ancestor scroll container
  • Typewriter mode bypasses the preservation behavior so its intentional centering remains unchanged

@vercel

vercel Bot commented Sep 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
markra-web Ready Ready Preview Sep 4, 2026 2:44pm UTC

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.

1 participant