From 1c9b984738aededd18390e5f015ace63e36e1b67 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 4 Dec 2023 23:35:31 +0000 Subject: [PATCH] Remove cx param --- crates/copilot_button2/src/copilot_button.rs | 3 +- crates/editor2/src/editor.rs | 1 - crates/editor2/src/mouse_context_menu.rs | 11 +++---- crates/project_panel2/src/project_panel.rs | 25 +++++++------- crates/terminal_view2/src/terminal_view.rs | 7 ++-- crates/ui2/src/components/context_menu.rs | 14 ++------ crates/workspace2/src/pane.rs | 34 ++++++-------------- 7 files changed, 31 insertions(+), 64 deletions(-) diff --git a/crates/copilot_button2/src/copilot_button.rs b/crates/copilot_button2/src/copilot_button.rs index aab59a9cad..dc6f808533 100644 --- a/crates/copilot_button2/src/copilot_button.rs +++ b/crates/copilot_button2/src/copilot_button.rs @@ -201,9 +201,8 @@ impl CopilotButton { url: COPILOT_SETTINGS_URL.to_string(), } .boxed_clone(), - cx, ) - .action("Sign Out", SignOut.boxed_clone(), cx) + .action("Sign Out", SignOut.boxed_clone()) }); } diff --git a/crates/editor2/src/editor.rs b/crates/editor2/src/editor.rs index dfad00036e..6b22324399 100644 --- a/crates/editor2/src/editor.rs +++ b/crates/editor2/src/editor.rs @@ -3640,7 +3640,6 @@ impl Editor { } pub fn toggle_code_actions(&mut self, action: &ToggleCodeActions, cx: &mut ViewContext) { - dbg!("TOGGLE CODE ACTIONS"); let mut context_menu = self.context_menu.write(); if matches!(context_menu.as_ref(), Some(ContextMenu::CodeActions(_))) { *context_menu = None; diff --git a/crates/editor2/src/mouse_context_menu.rs b/crates/editor2/src/mouse_context_menu.rs index fdeec9110b..8b998ccb3a 100644 --- a/crates/editor2/src/mouse_context_menu.rs +++ b/crates/editor2/src/mouse_context_menu.rs @@ -37,19 +37,18 @@ pub fn deploy_context_menu( }); let context_menu = ui::ContextMenu::build(cx, |menu, cx| { - menu.action("Rename Symbol", Box::new(Rename), cx) - .action("Go to Definition", Box::new(GoToDefinition), cx) - .action("Go to Type Definition", Box::new(GoToTypeDefinition), cx) - .action("Find All References", Box::new(FindAllReferences), cx) + menu.action("Rename Symbol", Box::new(Rename)) + .action("Go to Definition", Box::new(GoToDefinition)) + .action("Go to Type Definition", Box::new(GoToTypeDefinition)) + .action("Find All References", Box::new(FindAllReferences)) .action( "Code Actions", Box::new(ToggleCodeActions { deployed_from_indicator: false, }), - cx, ) .separator() - .action("Reveal in Finder", Box::new(RevealInFinder), cx) + .action("Reveal in Finder", Box::new(RevealInFinder)) }); let context_menu_focus = context_menu.focus_handle(cx); cx.focus(&context_menu_focus); diff --git a/crates/project_panel2/src/project_panel.rs b/crates/project_panel2/src/project_panel.rs index 0a5a63f14a..ce039071cf 100644 --- a/crates/project_panel2/src/project_panel.rs +++ b/crates/project_panel2/src/project_panel.rs @@ -397,7 +397,6 @@ impl ProjectPanel { menu = menu.action( "Add Folder to Project", Box::new(workspace::AddFolderToProject), - cx, ); if is_root { menu = menu.entry( @@ -412,35 +411,35 @@ impl ProjectPanel { } menu = menu - .action("New File", Box::new(NewFile), cx) - .action("New Folder", Box::new(NewDirectory), cx) + .action("New File", Box::new(NewFile)) + .action("New Folder", Box::new(NewDirectory)) .separator() - .action("Cut", Box::new(Cut), cx) - .action("Copy", Box::new(Copy), cx); + .action("Cut", Box::new(Cut)) + .action("Copy", Box::new(Copy)); if let Some(clipboard_entry) = self.clipboard_entry { if clipboard_entry.worktree_id() == worktree_id { - menu = menu.action("Paste", Box::new(Paste), cx); + menu = menu.action("Paste", Box::new(Paste)); } } menu = menu .separator() - .action("Copy Path", Box::new(CopyPath), cx) - .action("Copy Relative Path", Box::new(CopyRelativePath), cx) + .action("Copy Path", Box::new(CopyPath)) + .action("Copy Relative Path", Box::new(CopyRelativePath)) .separator() - .action("Reveal in Finder", Box::new(RevealInFinder), cx); + .action("Reveal in Finder", Box::new(RevealInFinder)); if is_dir { menu = menu - .action("Open in Terminal", Box::new(OpenInTerminal), cx) - .action("Search Inside", Box::new(NewSearchInDirectory), cx) + .action("Open in Terminal", Box::new(OpenInTerminal)) + .action("Search Inside", Box::new(NewSearchInDirectory)) } - menu = menu.separator().action("Rename", Box::new(Rename), cx); + menu = menu.separator().action("Rename", Box::new(Rename)); if !is_root { - menu = menu.action("Delete", Box::new(Delete), cx); + menu = menu.action("Delete", Box::new(Delete)); } menu diff --git a/crates/terminal_view2/src/terminal_view.rs b/crates/terminal_view2/src/terminal_view.rs index b007d58c34..4186a610bf 100644 --- a/crates/terminal_view2/src/terminal_view.rs +++ b/crates/terminal_view2/src/terminal_view.rs @@ -299,11 +299,8 @@ impl TerminalView { cx: &mut ViewContext, ) { self.context_menu = Some(ContextMenu::build(cx, |menu, cx| { - menu.action("Clear", Box::new(Clear), cx).action( - "Close", - Box::new(CloseActiveItem { save_intent: None }), - cx, - ) + menu.action("Clear", Box::new(Clear)) + .action("Close", Box::new(CloseActiveItem { save_intent: None })) })); dbg!(&position); // todo!() diff --git a/crates/ui2/src/components/context_menu.rs b/crates/ui2/src/components/context_menu.rs index 9a5390a8d5..27aa73b4fe 100644 --- a/crates/ui2/src/components/context_menu.rs +++ b/crates/ui2/src/components/context_menu.rs @@ -76,12 +76,7 @@ impl ContextMenu { self } - pub fn action( - mut self, - label: impl Into, - action: Box, - cx: &mut WindowContext, - ) -> Self { + pub fn action(mut self, label: impl Into, action: Box) -> Self { self.items.push(ContextMenuItem::Entry { label: label.into(), action: Some(action.boxed_clone()), @@ -91,12 +86,7 @@ impl ContextMenu { self } - pub fn link( - mut self, - label: impl Into, - action: Box, - cx: &mut WindowContext, - ) -> Self { + pub fn link(mut self, label: impl Into, action: Box) -> Self { self.items.push(ContextMenuItem::Entry { label: label.into(), action: Some(action.boxed_clone()), diff --git a/crates/workspace2/src/pane.rs b/crates/workspace2/src/pane.rs index 438ad39693..855ce0e931 100644 --- a/crates/workspace2/src/pane.rs +++ b/crates/workspace2/src/pane.rs @@ -1531,24 +1531,17 @@ impl Pane { menu.action( "Close Active Item", CloseActiveItem { save_intent: None }.boxed_clone(), - cx, - ) - .action("Close Inactive Items", CloseInactiveItems.boxed_clone(), cx) - .action("Close Clean Items", CloseCleanItems.boxed_clone(), cx) - .action( - "Close Items To The Left", - CloseItemsToTheLeft.boxed_clone(), - cx, ) + .action("Close Inactive Items", CloseInactiveItems.boxed_clone()) + .action("Close Clean Items", CloseCleanItems.boxed_clone()) + .action("Close Items To The Left", CloseItemsToTheLeft.boxed_clone()) .action( "Close Items To The Right", CloseItemsToTheRight.boxed_clone(), - cx, ) .action( "Close All Items", CloseAllItems { save_intent: None }.boxed_clone(), - cx, ) }) }) @@ -1627,17 +1620,12 @@ impl Pane { .child(IconButton::new("plus", Icon::Plus).on_click( cx.listener(|this, _, cx| { let menu = ContextMenu::build(cx, |menu, cx| { - menu.action("New File", NewFile.boxed_clone(), cx) + menu.action("New File", NewFile.boxed_clone()) .action( "New Terminal", NewCenterTerminal.boxed_clone(), - cx, - ) - .action( - "New Search", - NewSearch.boxed_clone(), - cx, ) + .action("New Search", NewSearch.boxed_clone()) }); cx.subscribe( &menu, @@ -1661,14 +1649,10 @@ impl Pane { .child(IconButton::new("split", Icon::Split).on_click( cx.listener(|this, _, cx| { let menu = ContextMenu::build(cx, |menu, cx| { - menu.action( - "Split Right", - SplitRight.boxed_clone(), - cx, - ) - .action("Split Left", SplitLeft.boxed_clone(), cx) - .action("Split Up", SplitUp.boxed_clone(), cx) - .action("Split Down", SplitDown.boxed_clone(), cx) + menu.action("Split Right", SplitRight.boxed_clone()) + .action("Split Left", SplitLeft.boxed_clone()) + .action("Split Up", SplitUp.boxed_clone()) + .action("Split Down", SplitDown.boxed_clone()) }); cx.subscribe( &menu,