Reproduction steps
- Open a Markdown file and open its preview tab (
markdown: open preview).
- Scroll partway down the document.
- Press
Cmd-F to open buffer search inside the preview.
- 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).
Reproduction steps
markdown: open preview).Cmd-Fto open buffer search inside the preview.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_changedrecords the pre-toggle bounds andautoscroll_verticallyshifts the scroll offset by the bounds delta on the next layout pass, anchoring visible content.Zed version and system specs
Notes
Cmd-F support was added to the markdown preview in #52502.
MarkdownPreviewViewimplementsSearchableItembut inherits the no-op default forsearch_bar_visibility_changedfromcrates/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).