From 442ea508c45bb4a26bd5954cbdfff07568c861f6 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 28 Jan 2025 17:08:51 -0800 Subject: [PATCH] Ensure hunk controls have unique element ids (#23815) This fixes an edge case when two hunk controls button groups were visible (due to having text cursor on one hunk, and mouse cursor on the other). In that situation, the mouse states for the two button groups would mirror. Release Notes: - N/A --- crates/editor/src/element.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 75c3313fa21508a1c900a90ecea9254c5c691a96..15b8fe58ced19891d9340a50572f668fab7a85b2 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -3829,8 +3829,13 @@ impl EditorElement { - scroll_pixel_position.y; let x = text_hitbox.bounds.right() - px(100.); - let mut element = - diff_hunk_controls(multi_buffer_range.clone(), line_height, &editor, cx); + let mut element = diff_hunk_controls( + display_row_range.start.0, + multi_buffer_range.clone(), + line_height, + &editor, + cx, + ); element.prepaint_as_root( gpui::Point::new(x, y), size(px(100.0), line_height).into(), @@ -8524,6 +8529,7 @@ mod tests { } fn diff_hunk_controls( + row: u32, hunk_range: Range, line_height: Pixels, editor: &Entity, @@ -8541,7 +8547,7 @@ fn diff_hunk_controls( .bg(cx.theme().colors().editor_background) .gap_1() .child( - IconButton::new("next-hunk", IconName::ArrowDown) + IconButton::new(("next-hunk", row as u64), IconName::ArrowDown) .shape(IconButtonShape::Square) .icon_size(IconSize::Small) // .disabled(!has_multiple_hunks) @@ -8564,7 +8570,7 @@ fn diff_hunk_controls( }), ) .child( - IconButton::new("prev-hunk", IconName::ArrowUp) + IconButton::new(("prev-hunk", row as u64), IconName::ArrowUp) .shape(IconButtonShape::Square) .icon_size(IconSize::Small) // .disabled(!has_multiple_hunks)