Remove cx param

This commit is contained in:
Conrad Irwin 2023-12-04 23:35:31 +00:00
parent c82fea375d
commit 1c9b984738
7 changed files with 31 additions and 64 deletions

View file

@ -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())
});
}

View file

@ -3640,7 +3640,6 @@ impl Editor {
}
pub fn toggle_code_actions(&mut self, action: &ToggleCodeActions, cx: &mut ViewContext<Self>) {
dbg!("TOGGLE CODE ACTIONS");
let mut context_menu = self.context_menu.write();
if matches!(context_menu.as_ref(), Some(ContextMenu::CodeActions(_))) {
*context_menu = None;

View file

@ -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);

View file

@ -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

View file

@ -299,11 +299,8 @@ impl TerminalView {
cx: &mut ViewContext<Self>,
) {
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!()

View file

@ -76,12 +76,7 @@ impl ContextMenu {
self
}
pub fn action(
mut self,
label: impl Into<SharedString>,
action: Box<dyn Action>,
cx: &mut WindowContext,
) -> Self {
pub fn action(mut self, label: impl Into<SharedString>, action: Box<dyn Action>) -> 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<SharedString>,
action: Box<dyn Action>,
cx: &mut WindowContext,
) -> Self {
pub fn link(mut self, label: impl Into<SharedString>, action: Box<dyn Action>) -> Self {
self.items.push(ContextMenuItem::Entry {
label: label.into(),
action: Some(action.boxed_clone()),

View file

@ -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,