From 8c3232bb9be79c98c5c9fb4d09fe508c292ca6b9 Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Tue, 21 Feb 2023 15:57:48 -0500 Subject: [PATCH] Add `reveal in finder` to additional locations Co-Authored-By: Julia <30666851+ForLoveOfCats@users.noreply.github.com> --- crates/editor/src/editor.rs | 12 +++++++++++- crates/editor/src/mouse_context_menu.rs | 4 +++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index dde01054704bdc63c20c06e18088192aa5202851..9aaaf765171f7a16a87976f36ebbd3ba4806afce 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) { + 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>) { self.highlighted_rows = rows; } diff --git a/crates/editor/src/mouse_context_menu.rs b/crates/editor/src/mouse_context_menu.rs index 77b58d1a0b272f125ded18a1e35045f7fec50bd1..ba48bb2b8d1a09cd12d9e1b1aaaa34e9835135d0 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, );