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
|
@ -37,7 +37,7 @@ use util::{maybe, NumericPrefixWithSuffix, ResultExt, TryFutureExt};
|
|||
use workspace::{
|
||||
dock::{DockPosition, Panel, PanelEvent},
|
||||
notifications::DetachAndPromptErr,
|
||||
Workspace,
|
||||
OpenInTerminal, Workspace,
|
||||
};
|
||||
|
||||
const PROJECT_PANEL_KEY: &str = "ProjectPanel";
|
||||
|
@ -127,7 +127,6 @@ actions!(
|
|||
CopyPath,
|
||||
CopyRelativePath,
|
||||
RevealInFinder,
|
||||
OpenInTerminal,
|
||||
Cut,
|
||||
Paste,
|
||||
Rename,
|
||||
|
@ -441,9 +440,7 @@ impl ProjectPanel {
|
|||
.action("New Folder", Box::new(NewDirectory))
|
||||
.separator()
|
||||
.action("Reveal in Finder", Box::new(RevealInFinder))
|
||||
.when(is_dir, |menu| {
|
||||
menu.action("Open in Terminal…", Box::new(OpenInTerminal))
|
||||
})
|
||||
.action("Open in Terminal", Box::new(OpenInTerminal))
|
||||
.when(is_dir, |menu| {
|
||||
menu.separator()
|
||||
.action("Find in Folder…", Box::new(NewSearchInDirectory))
|
||||
|
@ -1131,13 +1128,20 @@ impl ProjectPanel {
|
|||
|
||||
fn open_in_terminal(&mut self, _: &OpenInTerminal, cx: &mut ViewContext<Self>) {
|
||||
if let Some((worktree, entry)) = self.selected_entry(cx) {
|
||||
let path = worktree.abs_path().join(&entry.path);
|
||||
cx.dispatch_action(
|
||||
workspace::OpenTerminal {
|
||||
working_directory: path,
|
||||
let abs_path = worktree.abs_path().join(&entry.path);
|
||||
let working_directory = if entry.is_dir() {
|
||||
Some(abs_path)
|
||||
} else {
|
||||
if entry.is_symlink {
|
||||
abs_path.canonicalize().ok()
|
||||
} else {
|
||||
Some(abs_path)
|
||||
}
|
||||
.boxed_clone(),
|
||||
)
|
||||
.and_then(|path| Some(path.parent()?.to_path_buf()))
|
||||
};
|
||||
if let Some(working_directory) = working_directory {
|
||||
cx.dispatch_action(workspace::OpenTerminal { working_directory }.boxed_clone())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue