markdown_preview: Keep content anchored when search bar opens#55008
Closed
tkilaker wants to merge 2 commits into
Closed
markdown_preview: Keep content anchored when search bar opens#55008tkilaker wants to merge 2 commits into
tkilaker wants to merge 2 commits into
Conversation
Mirror the editor's `expect_bounds_change` pattern in `SearchableItem::search_bar_visibility_changed`: snapshot the preview's pre-toggle `bounds.top()`, then on the second `window.on_next_frame` (after the toolbar-grown frame has been painted) subtract the top delta from `scroll_handle.offset().y`. Matches the diff direction the editor uses at `crates/editor/src/scroll/autoscroll.rs:138`, accounting for `ScrollHandle::offset.y` being non-positive when scrolled down. Fixes zed-industries#54987.
|
We require contributors to sign our Contributor License Agreement, and we don't have @tkilaker on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
3 tasks
Contributor
Author
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
pull Bot
pushed a commit
to Jaleel-zhu/zed
that referenced
this pull request
May 15, 2026
…industries#55009) ## Summary - Changes the outer `MarkdownPreviewView` div from `.size_full()` to `.w_full().flex_1().min_h_0()`. - Before: preview's height stayed at 100% of the pane regardless of toolbar size, so deploying the buffer search bar pushed the preview's bottom 45px past the pane edge — clipped by the pane's `overflow_hidden`. - After: preview takes only the leftover main-axis space and shrinks as the toolbar grows. Bottom edge stays at the pane bottom. Verified empirically: `bounds.size.height` round-trips `952px ↔ 907px` with the toolbar at `67 ↔ 112` (Δ = 45px = the search bar's height). Companion to zed-industries#55008 (anchor compensation). Both PRs come out of investigating zed-industries#54987 — they fix two independent bugs that surface together when toggling the search bar. ## Test plan - [x] Compiles with `cargo clippy -p markdown_preview -- --deny warnings`. - [x] Manual: `Cmd-F` in the markdown preview no longer clips bottom content past the pane edge. - [x] Manual: `Esc` restores the preview to full available height. Release Notes: - Fixed markdown preview content being clipped past the pane edge when the buffer search bar is open Co-authored-by: Agus Zubiaga <agus@zed.dev>
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.
Summary
SearchableItem::search_bar_visibility_changedtoMarkdownPreviewView, mirroring the editor'sexpect_bounds_changepattern.window.on_next_framecallbacks because the first fires before the upcoming draw — the second sees the post-paint bounds. Subtracts the top delta fromScrollHandle::offset.y(which is non-positive when scrolled down) to scroll further down by exactly the toolbar's growth, holding content's screen position constant.Same root cause as the editor's
crates/editor/src/scroll/autoscroll.rs:138compensation —ScrollHandle::offset.yhas the opposite sign convention from the editor'sscroll_position.y, so we subtract instead of add.Fixes #54987.
Test plan
cargo clippy -p markdown_preview -- --deny warnings.Cmd-Fmid-document — content stays at same screen y; close + reopen returns offset to its original value (round-trip exact).offset.y == 0), no compensation runs (mirrors the editor's guard).Release Notes: