Add reveal in finder to additional locations

Co-Authored-By: Julia <30666851+ForLoveOfCats@users.noreply.github.com>
This commit is contained in:
Joseph Lyons 2023-02-21 15:57:48 -05:00
parent ebf1da1de8
commit 8c3232bb9b
2 changed files with 14 additions and 2 deletions

View file

@ -241,7 +241,8 @@ actions!(
RestartLanguageServer, RestartLanguageServer,
Hover, Hover,
Format, Format,
ToggleSoftWrap ToggleSoftWrap,
RevealInFinder
] ]
); );
@ -354,6 +355,7 @@ pub fn init(cx: &mut MutableAppContext) {
cx.add_action(Editor::open_excerpts); cx.add_action(Editor::open_excerpts);
cx.add_action(Editor::jump); cx.add_action(Editor::jump);
cx.add_action(Editor::toggle_soft_wrap); cx.add_action(Editor::toggle_soft_wrap);
cx.add_action(Editor::reveal_in_finder);
cx.add_async_action(Editor::format); cx.add_async_action(Editor::format);
cx.add_action(Editor::restart_language_server); cx.add_action(Editor::restart_language_server);
cx.add_action(Editor::show_character_palette); cx.add_action(Editor::show_character_palette);
@ -5889,6 +5891,14 @@ impl Editor {
cx.notify(); 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>>) { pub fn highlight_rows(&mut self, rows: Option<Range<u32>>) {
self.highlighted_rows = rows; self.highlighted_rows = rows;
} }

View file

@ -6,7 +6,7 @@ use gpui::{
use crate::{ use crate::{
DisplayPoint, Editor, EditorMode, FindAllReferences, GoToDefinition, GoToTypeDefinition, DisplayPoint, Editor, EditorMode, FindAllReferences, GoToDefinition, GoToTypeDefinition,
Rename, SelectMode, ToggleCodeActions, Rename, RevealInFinder, SelectMode, ToggleCodeActions,
}; };
#[derive(Clone, PartialEq)] #[derive(Clone, PartialEq)]
@ -61,6 +61,8 @@ pub fn deploy_context_menu(
deployed_from_indicator: false, deployed_from_indicator: false,
}, },
), ),
ContextMenuItem::Separator,
ContextMenuItem::item("Reveal in Finder", RevealInFinder),
], ],
cx, cx,
); );