Add "Open in Terminal" context menu entries for project panel, editor and tab context menus (#10741)
Closes https://github.com/zed-industries/zed/issues/4566 Pane tabs (does not exist for multibuffer tabs): <img width="439" alt="Screenshot 2024-04-18 at 23 01 08" src="https://github.com/zed-industries/zed/assets/2690773/3af79ed8-07ea-4cf2-bcf9-735b1b3be8c4"> Editor context menu: <img width="404" alt="Screenshot 2024-04-18 at 23 01 14" src="https://github.com/zed-industries/zed/assets/2690773/38ea7afc-df2b-45ef-8331-eb6a4588af9f"> Project panel context menu (was not shown for file entries before this): <img width="408" alt="Screenshot 2024-04-18 at 23 01 18" src="https://github.com/zed-industries/zed/assets/2690773/e336fce1-7da0-4671-b8d2-8d3409c23eb6"> Release Notes: - (breaking change) Moved `project_panel::OpenInTerminal` into `workspace::OpenInTerminal` action and add it in editors, tab context menus and proper panel file entries ([4566](https://github.com/zed-industries/zed/issues/4566))
This commit is contained in:
parent
250b71fb44
commit
870a61dd4d
7 changed files with 101 additions and 45 deletions
|
@ -98,7 +98,6 @@ impl TerminalPanel {
|
|||
.on_click(cx.listener(|pane, _, cx| {
|
||||
pane.toggle_zoom(&workspace::ToggleZoom, cx);
|
||||
}))
|
||||
// TODO kb
|
||||
.tooltip(move |cx| {
|
||||
Tooltip::for_action(
|
||||
if zoomed { "Zoom Out" } else { "Zoom In" },
|
||||
|
@ -292,13 +291,13 @@ impl TerminalPanel {
|
|||
action: &workspace::OpenTerminal,
|
||||
cx: &mut ViewContext<Workspace>,
|
||||
) {
|
||||
let Some(this) = workspace.focus_panel::<Self>(cx) else {
|
||||
let Some(terminal_panel) = workspace.panel::<Self>(cx) else {
|
||||
return;
|
||||
};
|
||||
|
||||
this.update(cx, |this, cx| {
|
||||
this.add_terminal(Some(action.working_directory.clone()), None, cx)
|
||||
})
|
||||
terminal_panel.update(cx, |panel, cx| {
|
||||
panel.add_terminal(Some(action.working_directory.clone()), None, cx)
|
||||
});
|
||||
workspace.focus_panel::<Self>(cx);
|
||||
}
|
||||
|
||||
fn spawn_task(&mut self, spawn_in_terminal: &SpawnInTerminal, cx: &mut ViewContext<Self>) {
|
||||
|
@ -427,26 +426,17 @@ impl TerminalPanel {
|
|||
}
|
||||
}
|
||||
|
||||
///Create a new Terminal in the current working directory or the user's home directory
|
||||
/// Create a new Terminal in the current working directory or the user's home directory
|
||||
fn new_terminal(
|
||||
workspace: &mut Workspace,
|
||||
_: &workspace::NewTerminal,
|
||||
cx: &mut ViewContext<Workspace>,
|
||||
) {
|
||||
let has_no_terminals = workspace
|
||||
.panel::<Self>(cx)
|
||||
.map(|terminal_panel| terminal_panel.update(cx, |panel, cx| panel.has_no_terminals(cx)))
|
||||
.unwrap_or(true);
|
||||
let Some(this) = workspace.focus_panel::<Self>(cx) else {
|
||||
let Some(terminal_panel) = workspace.panel::<Self>(cx) else {
|
||||
return;
|
||||
};
|
||||
if has_no_terminals {
|
||||
// `set_active` on focus, will already add a new terminal
|
||||
// into an empty terminal pane, no need to add another one
|
||||
return;
|
||||
}
|
||||
|
||||
this.update(cx, |this, cx| this.add_terminal(None, None, cx))
|
||||
terminal_panel.update(cx, |this, cx| this.add_terminal(None, None, cx));
|
||||
workspace.focus_panel::<Self>(cx);
|
||||
}
|
||||
|
||||
fn terminals_for_task(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue