1use crate::{DisplayPoint, Editor, EditorMode, SelectMode};
2use gpui::{Pixels, Point, ViewContext};
3
4pub fn deploy_context_menu(
5 editor: &mut Editor,
6 position: Point<Pixels>,
7 point: DisplayPoint,
8 cx: &mut ViewContext<Editor>,
9) {
10 todo!();
11
12 // if !editor.focused {
13 // cx.focus_self();
14 // }
15
16 // // Don't show context menu for inline editors
17 // if editor.mode() != EditorMode::Full {
18 // return;
19 // }
20
21 // // Don't show the context menu if there isn't a project associated with this editor
22 // if editor.project.is_none() {
23 // return;
24 // }
25
26 // // Move the cursor to the clicked location so that dispatched actions make sense
27 // editor.change_selections(None, cx, |s| {
28 // s.clear_disjoint();
29 // s.set_pending_display_range(point..point, SelectMode::Character);
30 // });
31
32 // editor.mouse_context_menu.update(cx, |menu, cx| {
33 // menu.show(
34 // position,
35 // AnchorCorner::TopLeft,
36 // vec![
37 // ContextMenuItem::action("Rename Symbol", Rename),
38 // ContextMenuItem::action("Go to Definition", GoToDefinition),
39 // ContextMenuItem::action("Go to Type Definition", GoToTypeDefinition),
40 // ContextMenuItem::action("Find All References", FindAllReferences),
41 // ContextMenuItem::action(
42 // "Code Actions",
43 // ToggleCodeActions {
44 // deployed_from_indicator: false,
45 // },
46 // ),
47 // ContextMenuItem::Separator,
48 // ContextMenuItem::action("Reveal in Finder", RevealInFinder),
49 // ],
50 // cx,
51 // );
52 // });
53 // cx.notify();
54}
55
56// #[cfg(test)]
57// mod tests {
58// use super::*;
59// use crate::{editor_tests::init_test, test::editor_lsp_test_context::EditorLspTestContext};
60// use indoc::indoc;
61
62// #[gpui::test]
63// async fn test_mouse_context_menu(cx: &mut gpui::TestAppContext) {
64// init_test(cx, |_| {});
65
66// let mut cx = EditorLspTestContext::new_rust(
67// lsp::ServerCapabilities {
68// hover_provider: Some(lsp::HoverProviderCapability::Simple(true)),
69// ..Default::default()
70// },
71// cx,
72// )
73// .await;
74
75// cx.set_state(indoc! {"
76// fn teˇst() {
77// do_work();
78// }
79// "});
80// let point = cx.display_point(indoc! {"
81// fn test() {
82// do_wˇork();
83// }
84// "});
85// cx.update_editor(|editor, cx| deploy_context_menu(editor, Default::default(), point, cx));
86
87// cx.assert_editor_state(indoc! {"
88// fn test() {
89// do_wˇork();
90// }
91// "});
92// cx.editor(|editor, app| assert!(editor.mouse_context_menu.read(app).visible()));
93// }
94// }