Skip to content

Search bars should not scroll down content on buffers or Markdown preview #54987

@tkilaker

Description

@tkilaker

Reproduction steps

  1. Open a Markdown file and open its preview tab (markdown: open preview).
  2. Scroll partway down the document.
  3. Press Cmd-F to open buffer search inside the preview.
  4. Observe: the line that was at the top of the viewport before the search bar opened is now drawn at a different screen position (or hidden behind the toolbar, depending on toolbar height).

Current vs. expected behavior

Current: When the search bar deploys, the pane's toolbar grows and the preview's viewport shrinks via flex layout. The preview keeps its scroll offset unchanged, so the same content is now drawn at a different screen position, visually sliding as the user toggles search. Navigating to a match whose position falls within the just-shrunk region can land the highlighted match underneath the search bar.

Expected: Toggling the search bar should keep the same content visible at the same screen position. The regular code editor already behaves this way: when its search bar deploys, Editor::search_bar_visibility_changed records the pre-toggle bounds and autoscroll_vertically shifts the scroll offset by the bounds delta on the next layout pass, anchoring visible content.

Zed version and system specs

Zed: v0.233.10+stable.250.350f33871e84d5ed83a403523e9490b9bf014a94 (Zed)
OS: macOS 26.5 (Build 25F5058e)
Memory: 32 GiB
Architecture: aarch64

Notes

Cmd-F support was added to the markdown preview in #52502. MarkdownPreviewView implements SearchableItem but inherits the no-op default for search_bar_visibility_changed from crates/workspace/src/searchable.rs, so it does not perform the same scroll-offset compensation as the editor (crates/editor/src/items.rs + crates/editor/src/scroll/autoscroll.rs).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:searchbuffer search, project search, etc
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions