From dc4f7249ffd00d8b5f8acf10741ff265726d9b35 Mon Sep 17 00:00:00 2001 From: Sahil Date: Sun, 24 Aug 2025 16:47:56 +0530 Subject: [PATCH 1/6] context menu is visible --- crates/editor/src/editor.rs | 2 +- crates/editor/src/element.rs | 65 ++++++++++++++++++++--------------- crates/git_ui/src/blame_ui.rs | 4 ++- 3 files changed, 42 insertions(+), 29 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 29e009fdf8..42d5887d26 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -6691,7 +6691,7 @@ impl Editor { } } - fn hide_blame_popover(&mut self, cx: &mut Context) { + pub fn hide_blame_popover(&mut self, cx: &mut Context) { self.inline_blame_popover_show_task.take(); if let Some(state) = &mut self.inline_blame_popover { let hide_task = cx.spawn(async move |editor, cx| { diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 32582ba941..df82419ca9 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1164,10 +1164,12 @@ impl EditorElement { .inline_blame_popover .as_ref() .is_some_and(|state| state.keyboard_grace); + let has_context_menu = editor.mouse_context_menu.is_some(); - if mouse_over_inline_blame || mouse_over_popover { + // Don't show blame popover if there's an active context menu + if (mouse_over_inline_blame || mouse_over_popover) && !has_context_menu { editor.show_blame_popover(blame_entry, event.position, false, cx); - } else if !keyboard_grace { + } else if !keyboard_grace || has_context_menu { editor.hide_blame_popover(cx); } } else { @@ -2532,32 +2534,41 @@ impl EditorElement { }); if let Some(mut element) = maybe_element { - let size = element.layout_as_root(AvailableSpace::min_size(), window, cx); - let overall_height = size.height + HOVER_POPOVER_GAP; - let popover_origin = if target_point.y > overall_height { - point(target_point.x, target_point.y - size.height) - } else { - point( - target_point.x, - target_point.y + line_height + HOVER_POPOVER_GAP, - ) - }; - - let horizontal_offset = (text_hitbox.top_right().x - - POPOVER_RIGHT_OFFSET - - (popover_origin.x + size.width)) - .min(Pixels::ZERO); - - let origin = point(popover_origin.x + horizontal_offset, popover_origin.y); - let popover_bounds = Bounds::new(origin, size); - - self.editor.update(cx, |editor, _| { - if let Some(state) = &mut editor.inline_blame_popover { - state.popover_bounds = Some(popover_bounds); - } + // Check if there's an active mouse context menu that would be obscured by the blame popover + let has_mouse_context_menu = self.editor.read_with(cx, |editor, _| { + editor.mouse_context_menu.is_some() }); - window.defer_draw(element, origin, 2); + // If there's a mouse context menu active, don't render the blame popover + // to prevent it from appearing on top of the context menu + if !has_mouse_context_menu { + let size = element.layout_as_root(AvailableSpace::min_size(), window, cx); + let overall_height = size.height + HOVER_POPOVER_GAP; + let popover_origin = if target_point.y > overall_height { + point(target_point.x, target_point.y - size.height) + } else { + point( + target_point.x, + target_point.y + line_height + HOVER_POPOVER_GAP, + ) + }; + + let horizontal_offset = (text_hitbox.top_right().x + - POPOVER_RIGHT_OFFSET + - (popover_origin.x + size.width)) + .min(Pixels::ZERO); + + let origin = point(popover_origin.x + horizontal_offset, popover_origin.y); + let popover_bounds = Bounds::new(origin, size); + + self.editor.update(cx, |editor, _| { + if let Some(state) = &mut editor.inline_blame_popover { + state.popover_bounds = Some(popover_bounds); + } + }); + + window.defer_draw(element, origin, 2); + } } } @@ -4779,7 +4790,7 @@ impl EditorElement { .anchor(Corner::TopLeft) .snap_to_window_with_margin(px(8.)), ) - .with_priority(1) + .with_priority(3) .into_any(), ) })?; diff --git a/crates/git_ui/src/blame_ui.rs b/crates/git_ui/src/blame_ui.rs index 2768e3dc68..9e7a8f17a6 100644 --- a/crates/git_ui/src/blame_ui.rs +++ b/crates/git_ui/src/blame_ui.rs @@ -99,7 +99,7 @@ impl BlameRenderer for GitBlameRenderer { ) } }) - .hoverable_tooltip(move |_window, cx| { + .tooltip(move |_window, cx| { cx.new(|cx| { CommitTooltip::blame_entry( &blame_entry, @@ -409,6 +409,8 @@ fn deploy_blame_entry_context_menu( }); editor.update(cx, move |editor, cx| { + // Hide any existing blame popover immediately when context menu is deployed + editor.hide_blame_popover(cx); editor.deploy_mouse_context_menu(position, context_menu, window, cx); cx.notify(); }); From 43c369b8c9df42ebff13af7d15bd13b060cb305e Mon Sep 17 00:00:00 2001 From: Sahil Date: Sun, 24 Aug 2025 16:54:58 +0530 Subject: [PATCH 2/6] not rendering git blame when context menu is visible --- crates/editor/src/editor.rs | 4 ++++ crates/git_ui/src/blame_ui.rs | 27 ++++++++++++++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 42d5887d26..ba94ddad8a 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -2410,6 +2410,10 @@ impl Editor { .is_some_and(|menu| menu.context_menu.focus_handle(cx).is_focused(window)) } + pub fn has_mouse_context_menu(&self) -> bool { + self.mouse_context_menu.is_some() + } + pub fn is_range_selected(&mut self, range: &Range, cx: &mut Context) -> bool { if self .selections diff --git a/crates/git_ui/src/blame_ui.rs b/crates/git_ui/src/blame_ui.rs index 9e7a8f17a6..4e1b9385b8 100644 --- a/crates/git_ui/src/blame_ui.rs +++ b/crates/git_ui/src/blame_ui.rs @@ -46,6 +46,9 @@ impl BlameRenderer for GitBlameRenderer { let author_name = blame_entry.author.as_deref().unwrap_or(""); let name = util::truncate_and_trailoff(author_name, GIT_BLAME_MAX_AUTHOR_CHARS_DISPLAYED); + let editor_for_mouse_down = editor.clone(); + let editor_for_tooltip = editor.clone(); + Some( h_flex() .w_full() @@ -73,7 +76,7 @@ impl BlameRenderer for GitBlameRenderer { deploy_blame_entry_context_menu( &blame_entry, details.as_ref(), - editor.clone(), + editor_for_mouse_down.clone(), event.position, window, cx, @@ -99,17 +102,19 @@ impl BlameRenderer for GitBlameRenderer { ) } }) - .tooltip(move |_window, cx| { - cx.new(|cx| { - CommitTooltip::blame_entry( - &blame_entry, - details.clone(), - repository.clone(), - workspace.clone(), - cx, - ) + .when(!editor_for_tooltip.read(cx).has_mouse_context_menu(), |el| { + el.tooltip(move |_window, cx| { + cx.new(|cx| { + CommitTooltip::blame_entry( + &blame_entry, + details.clone(), + repository.clone(), + workspace.clone(), + cx, + ) + }) + .into() }) - .into() }) .into_any(), ) From 737d1a9143b55ab671124ede4ca35e3151ae1fdc Mon Sep 17 00:00:00 2001 From: Sahil Date: Sun, 24 Aug 2025 17:13:28 +0530 Subject: [PATCH 3/6] fix: git blame popup overlaps with context menu --- crates/editor/src/element.rs | 4 ---- crates/git_ui/src/blame_ui.rs | 1 - 2 files changed, 5 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index df82419ca9..794a40e2de 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1166,7 +1166,6 @@ impl EditorElement { .is_some_and(|state| state.keyboard_grace); let has_context_menu = editor.mouse_context_menu.is_some(); - // Don't show blame popover if there's an active context menu if (mouse_over_inline_blame || mouse_over_popover) && !has_context_menu { editor.show_blame_popover(blame_entry, event.position, false, cx); } else if !keyboard_grace || has_context_menu { @@ -2534,13 +2533,10 @@ impl EditorElement { }); if let Some(mut element) = maybe_element { - // Check if there's an active mouse context menu that would be obscured by the blame popover let has_mouse_context_menu = self.editor.read_with(cx, |editor, _| { editor.mouse_context_menu.is_some() }); - // If there's a mouse context menu active, don't render the blame popover - // to prevent it from appearing on top of the context menu if !has_mouse_context_menu { let size = element.layout_as_root(AvailableSpace::min_size(), window, cx); let overall_height = size.height + HOVER_POPOVER_GAP; diff --git a/crates/git_ui/src/blame_ui.rs b/crates/git_ui/src/blame_ui.rs index 4e1b9385b8..276eb000d1 100644 --- a/crates/git_ui/src/blame_ui.rs +++ b/crates/git_ui/src/blame_ui.rs @@ -414,7 +414,6 @@ fn deploy_blame_entry_context_menu( }); editor.update(cx, move |editor, cx| { - // Hide any existing blame popover immediately when context menu is deployed editor.hide_blame_popover(cx); editor.deploy_mouse_context_menu(position, context_menu, window, cx); cx.notify(); From 00c641355c7ca480146089ae456a035ba6a93af7 Mon Sep 17 00:00:00 2001 From: Sahil Date: Sun, 24 Aug 2025 18:10:54 +0530 Subject: [PATCH 4/6] reverting back to use hoverable tooltip for git blame column view --- crates/git_ui/src/blame_ui.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/git_ui/src/blame_ui.rs b/crates/git_ui/src/blame_ui.rs index 276eb000d1..8ceede2f05 100644 --- a/crates/git_ui/src/blame_ui.rs +++ b/crates/git_ui/src/blame_ui.rs @@ -103,7 +103,7 @@ impl BlameRenderer for GitBlameRenderer { } }) .when(!editor_for_tooltip.read(cx).has_mouse_context_menu(), |el| { - el.tooltip(move |_window, cx| { + el.hoverable_tooltip(move |_window, cx| { cx.new(|cx| { CommitTooltip::blame_entry( &blame_entry, From 28a0cf5f88146e55c435f71b0ec79908225ac7a3 Mon Sep 17 00:00:00 2001 From: Sahil Date: Tue, 26 Aug 2025 16:01:08 +0530 Subject: [PATCH 5/6] ran cargo fmt --- crates/editor/src/element.rs | 6 +++--- crates/git_ui/src/blame_ui.rs | 29 ++++++++++++++++------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 794a40e2de..810b9c9bec 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -2533,9 +2533,9 @@ impl EditorElement { }); if let Some(mut element) = maybe_element { - let has_mouse_context_menu = self.editor.read_with(cx, |editor, _| { - editor.mouse_context_menu.is_some() - }); + let has_mouse_context_menu = self + .editor + .read_with(cx, |editor, _| editor.mouse_context_menu.is_some()); if !has_mouse_context_menu { let size = element.layout_as_root(AvailableSpace::min_size(), window, cx); diff --git a/crates/git_ui/src/blame_ui.rs b/crates/git_ui/src/blame_ui.rs index 8ceede2f05..58afc42603 100644 --- a/crates/git_ui/src/blame_ui.rs +++ b/crates/git_ui/src/blame_ui.rs @@ -102,20 +102,23 @@ impl BlameRenderer for GitBlameRenderer { ) } }) - .when(!editor_for_tooltip.read(cx).has_mouse_context_menu(), |el| { - el.hoverable_tooltip(move |_window, cx| { - cx.new(|cx| { - CommitTooltip::blame_entry( - &blame_entry, - details.clone(), - repository.clone(), - workspace.clone(), - cx, - ) + .when( + !editor_for_tooltip.read(cx).has_mouse_context_menu(), + |el| { + el.hoverable_tooltip(move |_window, cx| { + cx.new(|cx| { + CommitTooltip::blame_entry( + &blame_entry, + details.clone(), + repository.clone(), + workspace.clone(), + cx, + ) + }) + .into() }) - .into() - }) - }) + }, + ) .into_any(), ) } From 2841ec2c8c59d2f61426322c49904332a6c2bfa3 Mon Sep 17 00:00:00 2001 From: Sahil Date: Tue, 26 Aug 2025 19:23:33 +0530 Subject: [PATCH 6/6] fixed clippy error --- crates/git_ui/src/blame_ui.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/git_ui/src/blame_ui.rs b/crates/git_ui/src/blame_ui.rs index 58afc42603..f9dfd075df 100644 --- a/crates/git_ui/src/blame_ui.rs +++ b/crates/git_ui/src/blame_ui.rs @@ -47,7 +47,7 @@ impl BlameRenderer for GitBlameRenderer { let name = util::truncate_and_trailoff(author_name, GIT_BLAME_MAX_AUTHOR_CHARS_DISPLAYED); let editor_for_mouse_down = editor.clone(); - let editor_for_tooltip = editor.clone(); + let editor_for_tooltip = editor; Some( h_flex()