Skip to content

Markdown viewer: preserve scroll position when toggling Rendered/Raw views #14062

Description

@slash9494

Pre-submit Checks

Describe the solution you'd like?

When viewing a Markdown file, toggling between Rendered and Raw view modes should preserve the reading position instead of jumping back to the top of the document.

Expected behavior: scroll partway through a long Markdown file, toggle Rendered ⇄ Raw, and the new view opens at the equivalent position rather than at the top.

Is your feature request related to a problem? Please describe.

Today, toggling the view mode always resets the viewport to the top. The toggle replaces the entire pane (FileNotebookViewCodeView), and the new pane starts with a fresh scroll state, so any reading position is lost. On a long document this means re-scrolling from the top every time you switch modes to, e.g., check the raw source of a table or a link.

Because the two modes render different documents (rendered blocks vs. raw source lines), an exact line mapping isn't available; a proportional position (fraction of the scrollable range) is the practical target.

Additional context

This is the scroll-preservation half of #7897, which bundles two separate asks (scroll preservation and find/replace in the Markdown viewer). Filing this as a focused, single-scope issue to match the repo's Markdown viewer: … issue convention and to cleanly link an implementation.

PR #13967 implements this: it captures the outgoing pane's vertical scroll as a fraction of its scrollable range and re-applies it to the incoming pane after layout. The find/replace half of #7897 is intentionally out of scope here and can stay tracked on #7897 (or its own focused issue).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:editor-notebooksEditors, notebooks, markdown rendering, LSP, and code display.enhancementNew feature or request.ready-to-implementThe issue is ready for implementation work.repro:highThe report includes enough evidence that the issue appears highly reproducible.triagedIssue has received an initial automated triage pass.warp:auto-triage-review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions