From 3df8983debfa74eeece743385330a64b2c8ad5d4 Mon Sep 17 00:00:00 2001 From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Date: Fri, 19 Jun 2026 18:45:20 -0400 Subject: [PATCH] Fix picker preview for matches far down in files (#59621) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes picker previews for matches far down in a file by building the excerpt around the actual matched row instead of clamping it to the preview height estimate. ### Before Screenshot 2026-06-19 at 6 03
03 PM ### After Screenshot 2026-06-19 at 6 05
02 PM ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - N/A --- crates/picker/src/preview.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/picker/src/preview.rs b/crates/picker/src/preview.rs index a39818ac1a..cdfd0957f1 100644 --- a/crates/picker/src/preview.rs +++ b/crates/picker/src/preview.rs @@ -253,7 +253,8 @@ impl EditorPreview { const MIN_LINE_HEIGHT_PX: Pixels = px(6.0); const MARGIN: u32 = 2; // scrolling can offset things; - let max_rows = (window.viewport_size().height / MIN_LINE_HEIGHT_PX).ceil() as u32 + MARGIN; + let max_visible_rows = + (window.viewport_size().height / MIN_LINE_HEIGHT_PX).ceil() as u32 + MARGIN; self.preview_editor.update(cx, |editor, cx| { let focus_row = highlight @@ -264,8 +265,7 @@ impl EditorPreview { .to_point(&buffer.read(cx).text_snapshot()) .row }) - .unwrap_or_default() - .min(max_rows); + .unwrap_or_default(); let multi_buffer = editor.buffer().clone(); multi_buffer.update(cx, |multi_buffer, cx| { @@ -273,7 +273,7 @@ impl EditorPreview { multi_buffer.set_excerpts_for_buffer( buffer, [Point::new(focus_row, 0)..Point::new(focus_row, 0)], - max_rows, + max_visible_rows, cx, ); });