Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Add `reveal in finder` to additional locations

Joseph Lyons8c3232bb9be7
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index dde01054704..9aaaf765171 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -241,7 +241,8 @@ actions!(
RestartLanguageServer,
Hover,
Format,
- ToggleSoftWrap
+ ToggleSoftWrap,
+ RevealInFinder
]
);
@@ -354,6 +355,7 @@ pub fn init(cx: &mut MutableAppContext) {
cx.add_action(Editor::open_excerpts);
cx.add_action(Editor::jump);
cx.add_action(Editor::toggle_soft_wrap);
+ cx.add_action(Editor::reveal_in_finder);
cx.add_async_action(Editor::format);
cx.add_action(Editor::restart_language_server);
cx.add_action(Editor::show_character_palette);
@@ -5889,6 +5891,14 @@ impl Editor {
cx.notify();
}
+ pub fn reveal_in_finder(&mut self, _: &RevealInFinder, cx: &mut ViewContext<Self>) {
+ if let Some(buffer) = self.buffer().read(cx).as_singleton() {
+ if let Some(file) = buffer.read(cx).file().and_then(|f| f.as_local()) {
+ cx.reveal_path(&file.abs_path(cx));
+ }
+ }
+ }
+
pub fn highlight_rows(&mut self, rows: Option<Range<u32>>) {
self.highlighted_rows = rows;
}
diff --git a/crates/editor/src/mouse_context_menu.rs b/crates/editor/src/mouse_context_menu.rs
index 77b58d1a0b2..ba48bb2b8d1 100644
--- a/crates/editor/src/mouse_context_menu.rs
+++ b/crates/editor/src/mouse_context_menu.rs
@@ -6,7 +6,7 @@ use gpui::{
use crate::{
DisplayPoint, Editor, EditorMode, FindAllReferences, GoToDefinition, GoToTypeDefinition,
- Rename, SelectMode, ToggleCodeActions,
+ Rename, RevealInFinder, SelectMode, ToggleCodeActions,
};
#[derive(Clone, PartialEq)]
@@ -61,6 +61,8 @@ pub fn deploy_context_menu(
deployed_from_indicator: false,
},
),
+ ContextMenuItem::Separator,
+ ContextMenuItem::item("Reveal in Finder", RevealInFinder),
],
cx,
);