Remove cx param
This commit is contained in:
parent
c82fea375d
commit
1c9b984738
7 changed files with 31 additions and 64 deletions
|
@ -201,9 +201,8 @@ impl CopilotButton {
|
||||||
url: COPILOT_SETTINGS_URL.to_string(),
|
url: COPILOT_SETTINGS_URL.to_string(),
|
||||||
}
|
}
|
||||||
.boxed_clone(),
|
.boxed_clone(),
|
||||||
cx,
|
|
||||||
)
|
)
|
||||||
.action("Sign Out", SignOut.boxed_clone(), cx)
|
.action("Sign Out", SignOut.boxed_clone())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3640,7 +3640,6 @@ impl Editor {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle_code_actions(&mut self, action: &ToggleCodeActions, cx: &mut ViewContext<Self>) {
|
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();
|
let mut context_menu = self.context_menu.write();
|
||||||
if matches!(context_menu.as_ref(), Some(ContextMenu::CodeActions(_))) {
|
if matches!(context_menu.as_ref(), Some(ContextMenu::CodeActions(_))) {
|
||||||
*context_menu = None;
|
*context_menu = None;
|
||||||
|
|
|
@ -37,19 +37,18 @@ pub fn deploy_context_menu(
|
||||||
});
|
});
|
||||||
|
|
||||||
let context_menu = ui::ContextMenu::build(cx, |menu, cx| {
|
let context_menu = ui::ContextMenu::build(cx, |menu, cx| {
|
||||||
menu.action("Rename Symbol", Box::new(Rename), cx)
|
menu.action("Rename Symbol", Box::new(Rename))
|
||||||
.action("Go to Definition", Box::new(GoToDefinition), cx)
|
.action("Go to Definition", Box::new(GoToDefinition))
|
||||||
.action("Go to Type Definition", Box::new(GoToTypeDefinition), cx)
|
.action("Go to Type Definition", Box::new(GoToTypeDefinition))
|
||||||
.action("Find All References", Box::new(FindAllReferences), cx)
|
.action("Find All References", Box::new(FindAllReferences))
|
||||||
.action(
|
.action(
|
||||||
"Code Actions",
|
"Code Actions",
|
||||||
Box::new(ToggleCodeActions {
|
Box::new(ToggleCodeActions {
|
||||||
deployed_from_indicator: false,
|
deployed_from_indicator: false,
|
||||||
}),
|
}),
|
||||||
cx,
|
|
||||||
)
|
)
|
||||||
.separator()
|
.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);
|
let context_menu_focus = context_menu.focus_handle(cx);
|
||||||
cx.focus(&context_menu_focus);
|
cx.focus(&context_menu_focus);
|
||||||
|
|
|
@ -397,7 +397,6 @@ impl ProjectPanel {
|
||||||
menu = menu.action(
|
menu = menu.action(
|
||||||
"Add Folder to Project",
|
"Add Folder to Project",
|
||||||
Box::new(workspace::AddFolderToProject),
|
Box::new(workspace::AddFolderToProject),
|
||||||
cx,
|
|
||||||
);
|
);
|
||||||
if is_root {
|
if is_root {
|
||||||
menu = menu.entry(
|
menu = menu.entry(
|
||||||
|
@ -412,35 +411,35 @@ impl ProjectPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
menu = menu
|
menu = menu
|
||||||
.action("New File", Box::new(NewFile), cx)
|
.action("New File", Box::new(NewFile))
|
||||||
.action("New Folder", Box::new(NewDirectory), cx)
|
.action("New Folder", Box::new(NewDirectory))
|
||||||
.separator()
|
.separator()
|
||||||
.action("Cut", Box::new(Cut), cx)
|
.action("Cut", Box::new(Cut))
|
||||||
.action("Copy", Box::new(Copy), cx);
|
.action("Copy", Box::new(Copy));
|
||||||
|
|
||||||
if let Some(clipboard_entry) = self.clipboard_entry {
|
if let Some(clipboard_entry) = self.clipboard_entry {
|
||||||
if clipboard_entry.worktree_id() == worktree_id {
|
if clipboard_entry.worktree_id() == worktree_id {
|
||||||
menu = menu.action("Paste", Box::new(Paste), cx);
|
menu = menu.action("Paste", Box::new(Paste));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
menu = menu
|
menu = menu
|
||||||
.separator()
|
.separator()
|
||||||
.action("Copy Path", Box::new(CopyPath), cx)
|
.action("Copy Path", Box::new(CopyPath))
|
||||||
.action("Copy Relative Path", Box::new(CopyRelativePath), cx)
|
.action("Copy Relative Path", Box::new(CopyRelativePath))
|
||||||
.separator()
|
.separator()
|
||||||
.action("Reveal in Finder", Box::new(RevealInFinder), cx);
|
.action("Reveal in Finder", Box::new(RevealInFinder));
|
||||||
|
|
||||||
if is_dir {
|
if is_dir {
|
||||||
menu = menu
|
menu = menu
|
||||||
.action("Open in Terminal", Box::new(OpenInTerminal), cx)
|
.action("Open in Terminal", Box::new(OpenInTerminal))
|
||||||
.action("Search Inside", Box::new(NewSearchInDirectory), cx)
|
.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 {
|
if !is_root {
|
||||||
menu = menu.action("Delete", Box::new(Delete), cx);
|
menu = menu.action("Delete", Box::new(Delete));
|
||||||
}
|
}
|
||||||
|
|
||||||
menu
|
menu
|
||||||
|
|
|
@ -299,11 +299,8 @@ impl TerminalView {
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
self.context_menu = Some(ContextMenu::build(cx, |menu, cx| {
|
self.context_menu = Some(ContextMenu::build(cx, |menu, cx| {
|
||||||
menu.action("Clear", Box::new(Clear), cx).action(
|
menu.action("Clear", Box::new(Clear))
|
||||||
"Close",
|
.action("Close", Box::new(CloseActiveItem { save_intent: None }))
|
||||||
Box::new(CloseActiveItem { save_intent: None }),
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
}));
|
}));
|
||||||
dbg!(&position);
|
dbg!(&position);
|
||||||
// todo!()
|
// todo!()
|
||||||
|
|
|
@ -76,12 +76,7 @@ impl ContextMenu {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn action(
|
pub fn action(mut self, label: impl Into<SharedString>, action: Box<dyn Action>) -> Self {
|
||||||
mut self,
|
|
||||||
label: impl Into<SharedString>,
|
|
||||||
action: Box<dyn Action>,
|
|
||||||
cx: &mut WindowContext,
|
|
||||||
) -> Self {
|
|
||||||
self.items.push(ContextMenuItem::Entry {
|
self.items.push(ContextMenuItem::Entry {
|
||||||
label: label.into(),
|
label: label.into(),
|
||||||
action: Some(action.boxed_clone()),
|
action: Some(action.boxed_clone()),
|
||||||
|
@ -91,12 +86,7 @@ impl ContextMenu {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn link(
|
pub fn link(mut self, label: impl Into<SharedString>, action: Box<dyn Action>) -> Self {
|
||||||
mut self,
|
|
||||||
label: impl Into<SharedString>,
|
|
||||||
action: Box<dyn Action>,
|
|
||||||
cx: &mut WindowContext,
|
|
||||||
) -> Self {
|
|
||||||
self.items.push(ContextMenuItem::Entry {
|
self.items.push(ContextMenuItem::Entry {
|
||||||
label: label.into(),
|
label: label.into(),
|
||||||
action: Some(action.boxed_clone()),
|
action: Some(action.boxed_clone()),
|
||||||
|
|
|
@ -1531,24 +1531,17 @@ impl Pane {
|
||||||
menu.action(
|
menu.action(
|
||||||
"Close Active Item",
|
"Close Active Item",
|
||||||
CloseActiveItem { save_intent: None }.boxed_clone(),
|
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(
|
.action(
|
||||||
"Close Items To The Right",
|
"Close Items To The Right",
|
||||||
CloseItemsToTheRight.boxed_clone(),
|
CloseItemsToTheRight.boxed_clone(),
|
||||||
cx,
|
|
||||||
)
|
)
|
||||||
.action(
|
.action(
|
||||||
"Close All Items",
|
"Close All Items",
|
||||||
CloseAllItems { save_intent: None }.boxed_clone(),
|
CloseAllItems { save_intent: None }.boxed_clone(),
|
||||||
cx,
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1627,17 +1620,12 @@ impl Pane {
|
||||||
.child(IconButton::new("plus", Icon::Plus).on_click(
|
.child(IconButton::new("plus", Icon::Plus).on_click(
|
||||||
cx.listener(|this, _, cx| {
|
cx.listener(|this, _, cx| {
|
||||||
let menu = ContextMenu::build(cx, |menu, cx| {
|
let menu = ContextMenu::build(cx, |menu, cx| {
|
||||||
menu.action("New File", NewFile.boxed_clone(), cx)
|
menu.action("New File", NewFile.boxed_clone())
|
||||||
.action(
|
.action(
|
||||||
"New Terminal",
|
"New Terminal",
|
||||||
NewCenterTerminal.boxed_clone(),
|
NewCenterTerminal.boxed_clone(),
|
||||||
cx,
|
|
||||||
)
|
|
||||||
.action(
|
|
||||||
"New Search",
|
|
||||||
NewSearch.boxed_clone(),
|
|
||||||
cx,
|
|
||||||
)
|
)
|
||||||
|
.action("New Search", NewSearch.boxed_clone())
|
||||||
});
|
});
|
||||||
cx.subscribe(
|
cx.subscribe(
|
||||||
&menu,
|
&menu,
|
||||||
|
@ -1661,14 +1649,10 @@ impl Pane {
|
||||||
.child(IconButton::new("split", Icon::Split).on_click(
|
.child(IconButton::new("split", Icon::Split).on_click(
|
||||||
cx.listener(|this, _, cx| {
|
cx.listener(|this, _, cx| {
|
||||||
let menu = ContextMenu::build(cx, |menu, cx| {
|
let menu = ContextMenu::build(cx, |menu, cx| {
|
||||||
menu.action(
|
menu.action("Split Right", SplitRight.boxed_clone())
|
||||||
"Split Right",
|
.action("Split Left", SplitLeft.boxed_clone())
|
||||||
SplitRight.boxed_clone(),
|
.action("Split Up", SplitUp.boxed_clone())
|
||||||
cx,
|
.action("Split Down", SplitDown.boxed_clone())
|
||||||
)
|
|
||||||
.action("Split Left", SplitLeft.boxed_clone(), cx)
|
|
||||||
.action("Split Up", SplitUp.boxed_clone(), cx)
|
|
||||||
.action("Split Down", SplitDown.boxed_clone(), cx)
|
|
||||||
});
|
});
|
||||||
cx.subscribe(
|
cx.subscribe(
|
||||||
&menu,
|
&menu,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue