Move open command handler to workspace global action
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
co-authored by
Nathan Sobo
parent
3247f49954
commit
2332b7e06b
@@ -8,11 +8,15 @@ pub use pane_group::*;
|
||||
pub use workspace::*;
|
||||
pub use workspace_view::*;
|
||||
|
||||
use crate::{settings::Settings, watch};
|
||||
use gpui::MutableAppContext;
|
||||
use crate::{
|
||||
settings::Settings,
|
||||
watch::{self, Receiver},
|
||||
};
|
||||
use gpui::{MutableAppContext, PathPromptOptions};
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn init(app: &mut MutableAppContext) {
|
||||
app.add_global_action("workspace:open", open);
|
||||
app.add_global_action("workspace:open_paths", open_paths);
|
||||
app.add_global_action("app:quit", quit);
|
||||
pane::init(app);
|
||||
@@ -24,6 +28,22 @@ pub struct OpenParams {
|
||||
pub settings: watch::Receiver<Settings>,
|
||||
}
|
||||
|
||||
fn open(settings: &Receiver<Settings>, ctx: &mut MutableAppContext) {
|
||||
if let Some(paths) = ctx.platform().prompt_for_paths(PathPromptOptions {
|
||||
files: true,
|
||||
directories: true,
|
||||
multiple: true,
|
||||
}) {
|
||||
ctx.dispatch_global_action(
|
||||
"workspace:open_paths",
|
||||
OpenParams {
|
||||
paths,
|
||||
settings: settings.clone(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn open_paths(params: &OpenParams, app: &mut MutableAppContext) {
|
||||
log::info!("open paths {:?}", params.paths);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user