Remove DeployMouseContextMenu internal action
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
co-authored by
Nathan Sobo
parent
c22342e271
commit
3409ee1785
@@ -386,7 +386,6 @@ pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(Editor::copilot_suggest);
|
||||
|
||||
hover_popover::init(cx);
|
||||
mouse_context_menu::init(cx);
|
||||
scroll::actions::init(cx);
|
||||
|
||||
workspace::register_project_item::<Editor>(cx);
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::{
|
||||
link_go_to_definition::{
|
||||
go_to_fetched_definition, go_to_fetched_type_definition, update_go_to_definition_link,
|
||||
},
|
||||
mouse_context_menu::DeployMouseContextMenu,
|
||||
mouse_context_menu,
|
||||
scroll::actions::Scroll,
|
||||
EditorStyle, GutterHover, UnfoldAt,
|
||||
};
|
||||
@@ -131,8 +131,9 @@ impl EditorElement {
|
||||
})
|
||||
.on_down(MouseButton::Right, {
|
||||
let position_map = position_map.clone();
|
||||
move |event, _editor, cx| {
|
||||
move |event, editor, cx| {
|
||||
if !Self::mouse_right_down(
|
||||
editor,
|
||||
event.position,
|
||||
position_map.as_ref(),
|
||||
text_bounds,
|
||||
@@ -278,6 +279,7 @@ impl EditorElement {
|
||||
}
|
||||
|
||||
fn mouse_right_down(
|
||||
editor: &mut Editor,
|
||||
position: Vector2F,
|
||||
position_map: &PositionMap,
|
||||
text_bounds: RectF,
|
||||
@@ -288,8 +290,7 @@ impl EditorElement {
|
||||
}
|
||||
|
||||
let (point, _) = position_map.point_for_position(text_bounds, position);
|
||||
|
||||
cx.dispatch_action(DeployMouseContextMenu { position, point });
|
||||
mouse_context_menu::deploy_context_menu(editor, position, point, cx);
|
||||
true
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +1,14 @@
|
||||
use context_menu::ContextMenuItem;
|
||||
use gpui::{
|
||||
elements::AnchorCorner, geometry::vector::Vector2F, impl_internal_actions, AppContext,
|
||||
ViewContext,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
DisplayPoint, Editor, EditorMode, FindAllReferences, GoToDefinition, GoToTypeDefinition,
|
||||
Rename, RevealInFinder, SelectMode, ToggleCodeActions,
|
||||
};
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct DeployMouseContextMenu {
|
||||
pub position: Vector2F,
|
||||
pub point: DisplayPoint,
|
||||
}
|
||||
|
||||
impl_internal_actions!(editor, [DeployMouseContextMenu]);
|
||||
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(deploy_context_menu);
|
||||
}
|
||||
use context_menu::ContextMenuItem;
|
||||
use gpui::{elements::AnchorCorner, geometry::vector::Vector2F, ViewContext};
|
||||
|
||||
pub fn deploy_context_menu(
|
||||
editor: &mut Editor,
|
||||
&DeployMouseContextMenu { position, point }: &DeployMouseContextMenu,
|
||||
position: Vector2F,
|
||||
point: DisplayPoint,
|
||||
cx: &mut ViewContext<Editor>,
|
||||
) {
|
||||
if !editor.focused {
|
||||
@@ -98,16 +83,7 @@ mod tests {
|
||||
do_wˇork();
|
||||
}
|
||||
"});
|
||||
cx.update_editor(|editor, cx| {
|
||||
deploy_context_menu(
|
||||
editor,
|
||||
&DeployMouseContextMenu {
|
||||
position: Default::default(),
|
||||
point,
|
||||
},
|
||||
cx,
|
||||
)
|
||||
});
|
||||
cx.update_editor(|editor, cx| deploy_context_menu(editor, Default::default(), point, cx));
|
||||
|
||||
cx.assert_editor_state(indoc! {"
|
||||
fn test() {
|
||||
|
||||
Reference in New Issue
Block a user