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