From b224b2118c371a1af12e9aa2bcc62340ae5a1058 Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Mon, 2 Mar 2026 08:33:06 +0000 Subject: [PATCH] editor: Fix sticky diff hunk controls not being flush to buffer headers (#50402) (cherry-pick to preview) (#50467) Cherry-pick of #50402 to preview ---- Release Notes: - Fixed a visual gap between diff hunk controls and buffer headers Co-authored-by: Lukas Wirth --- crates/editor/src/editor.rs | 1 + crates/editor/src/element.rs | 32 ++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 1a0a66b7b6074df549d932d4488013d48f7f3f5e..fe97f3d2760f2242851bf5bbfa3c16caca55ecb0 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -237,6 +237,7 @@ use crate::{ }; pub const FILE_HEADER_HEIGHT: u32 = 2; +pub const BUFFER_HEADER_PADDING: Rems = rems(0.25); pub const MULTI_BUFFER_EXCERPT_HEADER_HEIGHT: u32 = 1; const CURSOR_BLINK_INTERVAL: Duration = Duration::from_millis(500); const MAX_LINE_LEN: usize = 1024; diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 8131cdcb9e94754b03b6fc672d05652107a7e6b9..78550963ce2b4d093c655825f42fdc2db60284bb 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1,15 +1,15 @@ use crate::{ - ActiveDiagnostic, BlockId, CURSORS_VISIBLE_FOR, ChunkRendererContext, ChunkReplacement, - CodeActionSource, ColumnarMode, ConflictsOurs, ConflictsOursMarker, ConflictsOuter, - ConflictsTheirs, ConflictsTheirsMarker, ContextMenuPlacement, CursorShape, CustomBlockId, - DisplayDiffHunk, DisplayPoint, DisplayRow, EditDisplayMode, EditPrediction, Editor, EditorMode, - EditorSettings, EditorSnapshot, EditorStyle, FILE_HEADER_HEIGHT, FocusedBlock, - GutterDimensions, HalfPageDown, HalfPageUp, HandleInput, HoveredCursor, InlayHintRefreshReason, - JumpData, LineDown, LineHighlight, LineUp, MAX_LINE_LEN, MINIMAP_FONT_SIZE, - MULTI_BUFFER_EXCERPT_HEADER_HEIGHT, OpenExcerpts, PageDown, PageUp, PhantomBreakpointIndicator, - PhantomDiffReviewIndicator, Point, RowExt, RowRangeExt, SelectPhase, Selection, - SelectionDragState, SelectionEffects, SizingBehavior, SoftWrap, StickyHeaderExcerpt, ToPoint, - ToggleFold, ToggleFoldAll, + ActiveDiagnostic, BUFFER_HEADER_PADDING, BlockId, CURSORS_VISIBLE_FOR, ChunkRendererContext, + ChunkReplacement, CodeActionSource, ColumnarMode, ConflictsOurs, ConflictsOursMarker, + ConflictsOuter, ConflictsTheirs, ConflictsTheirsMarker, ContextMenuPlacement, CursorShape, + CustomBlockId, DisplayDiffHunk, DisplayPoint, DisplayRow, EditDisplayMode, EditPrediction, + Editor, EditorMode, EditorSettings, EditorSnapshot, EditorStyle, FILE_HEADER_HEIGHT, + FocusedBlock, GutterDimensions, HalfPageDown, HalfPageUp, HandleInput, HoveredCursor, + InlayHintRefreshReason, JumpData, LineDown, LineHighlight, LineUp, MAX_LINE_LEN, + MINIMAP_FONT_SIZE, MULTI_BUFFER_EXCERPT_HEADER_HEIGHT, OpenExcerpts, PageDown, PageUp, + PhantomBreakpointIndicator, PhantomDiffReviewIndicator, Point, RowExt, RowRangeExt, + SelectPhase, Selection, SelectionDragState, SelectionEffects, SizingBehavior, SoftWrap, + StickyHeaderExcerpt, ToPoint, ToggleFold, ToggleFoldAll, code_context_menus::{CodeActionsMenu, MENU_ASIDE_MAX_WIDTH, MENU_ASIDE_MIN_WIDTH, MENU_GAP}, column_pixels, display_map::{ @@ -8138,7 +8138,7 @@ pub(crate) fn render_buffer_header( let header = div() .id(("buffer-header", for_excerpt.buffer_id.to_proto())) - .p_1() + .p(BUFFER_HEADER_PADDING) .w_full() .h(FILE_HEADER_HEIGHT as f32 * window.line_height()) .child( @@ -10807,7 +10807,9 @@ impl Element for EditorElement { .and_then(|headers| headers.lines.last()) .map_or(Pixels::ZERO, |last| last.offset + line_height); - let sticky_header_height = if sticky_buffer_header.is_some() { + let has_sticky_buffer_header = + sticky_buffer_header.is_some() || sticky_header_excerpt_id.is_some(); + let sticky_header_height = if has_sticky_buffer_header { let full_height = FILE_HEADER_HEIGHT as f32 * line_height; let display_row = blocks .iter() @@ -10826,7 +10828,9 @@ impl Element for EditorElement { } None => full_height, }; - sticky_scroll_header_height + offset + let header_bottom_padding = + BUFFER_HEADER_PADDING.to_pixels(window.rem_size()); + sticky_scroll_header_height + offset - header_bottom_padding } else { sticky_scroll_header_height };