Add editor mouse context menu with some basic refactorings and an entry to pop the code actions

This commit is contained in:
Keith Simmons 2022-07-12 13:34:23 -07:00 committed by K Simmons
parent d796b543e0
commit b850e41d6f

View file

@ -1,11 +1,9 @@
use context_menu::{ContextMenu, ContextMenuItem};
use gpui::{
geometry::vector::Vector2F, impl_internal_actions, MutableAppContext, Task, ViewContext,
ViewHandle,
};
use context_menu::ContextMenuItem;
use gpui::{geometry::vector::Vector2F, impl_internal_actions, MutableAppContext, ViewContext};
use crate::{
DisplayPoint, Editor, EditorMode, FindAllReferences, GoToDefinition, Rename, SelectMode,
ToggleCodeActions,
};
#[derive(Clone, PartialEq)]
@ -20,11 +18,6 @@ pub fn init(cx: &mut MutableAppContext) {
cx.add_action(deploy_context_menu);
}
pub struct MouseContextMenuState {
pub context_menu: ViewHandle<ContextMenu>,
pub task: Option<Task<()>>,
}
pub fn deploy_context_menu(
editor: &mut Editor,
&DeployMouseContextMenu { position, point }: &DeployMouseContextMenu,
@ -53,6 +46,12 @@ pub fn deploy_context_menu(
ContextMenuItem::item("Rename Symbol", Rename),
ContextMenuItem::item("Go To Definition", GoToDefinition),
ContextMenuItem::item("Find All References", FindAllReferences),
ContextMenuItem::item(
"Code Actions",
ToggleCodeActions {
deployed_from_indicator: false,
},
),
],
cx,
);