Skip to content

Commit

Permalink
add "Reveal in File Explorer" to right_click of editor (lapce#3437)
Browse files Browse the repository at this point in the history
  • Loading branch information
jm-observer authored Aug 14, 2024
1 parent 81f3838 commit 1f22a05
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lapce-app/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ pub enum LapceWorkbenchCommand {
#[strum(message = "Reveal in File Tree")]
RevealInFileTree,

#[strum(serialize = "reveal_in_file_explorer")]
#[strum(message = "Reveal in File Explorer")]
RevealInFileExplorer,

#[strum(serialize = "run_in_terminal")]
#[strum(message = "Run in Terminal")]
RunInTerminal,
Expand Down
3 changes: 3 additions & 0 deletions lapce-app/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2746,6 +2746,9 @@ impl EditorData {
Some(CommandKind::Workbench(
LapceWorkbenchCommand::RevealInFileTree,
)),
Some(CommandKind::Workbench(
LapceWorkbenchCommand::RevealInFileExplorer,
)),
Some(CommandKind::Workbench(
LapceWorkbenchCommand::PaletteCommand,
)),
Expand Down
18 changes: 18 additions & 0 deletions lapce-app/src/window_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,24 @@ impl WindowTabData {
}
}
}
RevealInFileExplorer => {
if let Some(editor_data) =
self.main_split.active_editor.get_untracked()
{
if let DocContent::File {path, ..} = editor_data.doc().content.get_untracked() {
let path = path.parent().unwrap_or(&path);
if !path.exists() {
return;
}
if let Err(err) = open::that(path) {
error!(
"Failed to reveal file in system file explorer: {}",
err
);
}
}
}
}
ShowCallHierarchy => {
if let Some(editor_data) =
self.main_split.active_editor.get_untracked()
Expand Down

0 comments on commit 1f22a05

Please sign in to comment.