Merge 2841ec2c8c
into bd4e943597
This commit is contained in:
commit
594735fcc5
3 changed files with 59 additions and 39 deletions
|
@ -2410,6 +2410,10 @@ impl Editor {
|
||||||
.is_some_and(|menu| menu.context_menu.focus_handle(cx).is_focused(window))
|
.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<Anchor>, cx: &mut Context<Self>) -> bool {
|
pub fn is_range_selected(&mut self, range: &Range<Anchor>, cx: &mut Context<Self>) -> bool {
|
||||||
if self
|
if self
|
||||||
.selections
|
.selections
|
||||||
|
@ -6691,7 +6695,7 @@ impl Editor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hide_blame_popover(&mut self, cx: &mut Context<Self>) {
|
pub fn hide_blame_popover(&mut self, cx: &mut Context<Self>) {
|
||||||
self.inline_blame_popover_show_task.take();
|
self.inline_blame_popover_show_task.take();
|
||||||
if let Some(state) = &mut self.inline_blame_popover {
|
if let Some(state) = &mut self.inline_blame_popover {
|
||||||
let hide_task = cx.spawn(async move |editor, cx| {
|
let hide_task = cx.spawn(async move |editor, cx| {
|
||||||
|
|
|
@ -1164,10 +1164,11 @@ impl EditorElement {
|
||||||
.inline_blame_popover
|
.inline_blame_popover
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.is_some_and(|state| state.keyboard_grace);
|
.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 {
|
if (mouse_over_inline_blame || mouse_over_popover) && !has_context_menu {
|
||||||
editor.show_blame_popover(blame_entry, event.position, false, cx);
|
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);
|
editor.hide_blame_popover(cx);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2532,32 +2533,38 @@ impl EditorElement {
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(mut element) = maybe_element {
|
if let Some(mut element) = maybe_element {
|
||||||
let size = element.layout_as_root(AvailableSpace::min_size(), window, cx);
|
let has_mouse_context_menu = self
|
||||||
let overall_height = size.height + HOVER_POPOVER_GAP;
|
.editor
|
||||||
let popover_origin = if target_point.y > overall_height {
|
.read_with(cx, |editor, _| editor.mouse_context_menu.is_some());
|
||||||
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
|
if !has_mouse_context_menu {
|
||||||
- POPOVER_RIGHT_OFFSET
|
let size = element.layout_as_root(AvailableSpace::min_size(), window, cx);
|
||||||
- (popover_origin.x + size.width))
|
let overall_height = size.height + HOVER_POPOVER_GAP;
|
||||||
.min(Pixels::ZERO);
|
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 origin = point(popover_origin.x + horizontal_offset, popover_origin.y);
|
let horizontal_offset = (text_hitbox.top_right().x
|
||||||
let popover_bounds = Bounds::new(origin, size);
|
- POPOVER_RIGHT_OFFSET
|
||||||
|
- (popover_origin.x + size.width))
|
||||||
|
.min(Pixels::ZERO);
|
||||||
|
|
||||||
self.editor.update(cx, |editor, _| {
|
let origin = point(popover_origin.x + horizontal_offset, popover_origin.y);
|
||||||
if let Some(state) = &mut editor.inline_blame_popover {
|
let popover_bounds = Bounds::new(origin, size);
|
||||||
state.popover_bounds = Some(popover_bounds);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
window.defer_draw(element, origin, 2);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4790,7 +4797,7 @@ impl EditorElement {
|
||||||
.anchor(Corner::TopLeft)
|
.anchor(Corner::TopLeft)
|
||||||
.snap_to_window_with_margin(px(8.)),
|
.snap_to_window_with_margin(px(8.)),
|
||||||
)
|
)
|
||||||
.with_priority(1)
|
.with_priority(3)
|
||||||
.into_any(),
|
.into_any(),
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
|
@ -46,6 +46,9 @@ impl BlameRenderer for GitBlameRenderer {
|
||||||
let author_name = blame_entry.author.as_deref().unwrap_or("<no name>");
|
let author_name = blame_entry.author.as_deref().unwrap_or("<no name>");
|
||||||
let name = util::truncate_and_trailoff(author_name, GIT_BLAME_MAX_AUTHOR_CHARS_DISPLAYED);
|
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;
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
h_flex()
|
h_flex()
|
||||||
.w_full()
|
.w_full()
|
||||||
|
@ -73,7 +76,7 @@ impl BlameRenderer for GitBlameRenderer {
|
||||||
deploy_blame_entry_context_menu(
|
deploy_blame_entry_context_menu(
|
||||||
&blame_entry,
|
&blame_entry,
|
||||||
details.as_ref(),
|
details.as_ref(),
|
||||||
editor.clone(),
|
editor_for_mouse_down.clone(),
|
||||||
event.position,
|
event.position,
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
|
@ -99,18 +102,23 @@ impl BlameRenderer for GitBlameRenderer {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.hoverable_tooltip(move |_window, cx| {
|
.when(
|
||||||
cx.new(|cx| {
|
!editor_for_tooltip.read(cx).has_mouse_context_menu(),
|
||||||
CommitTooltip::blame_entry(
|
|el| {
|
||||||
&blame_entry,
|
el.hoverable_tooltip(move |_window, cx| {
|
||||||
details.clone(),
|
cx.new(|cx| {
|
||||||
repository.clone(),
|
CommitTooltip::blame_entry(
|
||||||
workspace.clone(),
|
&blame_entry,
|
||||||
cx,
|
details.clone(),
|
||||||
)
|
repository.clone(),
|
||||||
})
|
workspace.clone(),
|
||||||
.into()
|
cx,
|
||||||
})
|
)
|
||||||
|
})
|
||||||
|
.into()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
.into_any(),
|
.into_any(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -409,6 +417,7 @@ fn deploy_blame_entry_context_menu(
|
||||||
});
|
});
|
||||||
|
|
||||||
editor.update(cx, move |editor, cx| {
|
editor.update(cx, move |editor, cx| {
|
||||||
|
editor.hide_blame_popover(cx);
|
||||||
editor.deploy_mouse_context_menu(position, context_menu, window, cx);
|
editor.deploy_mouse_context_menu(position, context_menu, window, cx);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue