From f5e155b5a9d9c47a12ea51e73bfe6fff9aa4b759 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 3 May 2024 16:44:33 +0300 Subject: [PATCH] When clicking on a hunk expand it, do not move the caret (#11350) Release Notes: - N/A --- crates/editor/src/element.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index eda06a95c9..9c925b4b00 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -427,10 +427,12 @@ impl EditorElement { let mut click_count = event.click_count; let mut modifiers = event.modifiers; - if gutter_hitbox.is_hovered(cx) { - click_count = 3; // Simulate triple-click when clicking the gutter to select lines - } else if let Some(hovered_hunk) = hovered_hunk { + if let Some(hovered_hunk) = hovered_hunk { editor.expand_diff_hunk(None, hovered_hunk, cx); + cx.notify(); + return; + } else if gutter_hitbox.is_hovered(cx) { + click_count = 3; // Simulate triple-click when clicking the gutter to select lines } else if !text_hitbox.is_hovered(cx) { return; }