Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/gpui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,9 @@ impl App {
pub fn prompt_for_paths(
&self,
options: PathPromptOptions,
initial_path: Option<String>
) -> oneshot::Receiver<Result<Option<Vec<PathBuf>>>> {
self.platform.prompt_for_paths(options)
self.platform.prompt_for_paths(options, initial_path)
}

/// Displays a platform modal for selecting a new path where a file can be saved.
Expand Down
1 change: 1 addition & 0 deletions crates/gpui/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ pub(crate) trait Platform: 'static {
fn prompt_for_paths(
&self,
options: PathPromptOptions,
initial_path: Option<String>,
) -> oneshot::Receiver<Result<Option<Vec<PathBuf>>>>;
fn prompt_for_new_path(&self, directory: &Path) -> oneshot::Receiver<Result<Option<PathBuf>>>;
fn can_select_mixed_files_and_dirs(&self) -> bool;
Expand Down
24 changes: 19 additions & 5 deletions crates/gpui/src/platform/linux/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ impl<P: LinuxClient + 'static> Platform for P {
fn prompt_for_paths(
&self,
options: PathPromptOptions,
initial_path: Option<String>,
) -> oneshot::Receiver<Result<Option<Vec<PathBuf>>>> {
let (done_tx, done_rx) = oneshot::channel();

Expand All @@ -290,14 +291,27 @@ impl<P: LinuxClient + 'static> Platform for P {
"Open File"
};

let request = match ashpd::desktop::file_chooser::OpenFileRequest::default()
let req = ashpd::desktop::file_chooser::OpenFileRequest::default()
.modal(true)
.title(title)
.multiple(options.multiple)
.directory(options.directories)
.send()
.await
{
.directory(options.directories);

let req2 = if let Some(initpath) = initial_path {
if let Ok(r) = req.current_folder(initpath) {
r
} else {
ashpd::desktop::file_chooser::OpenFileRequest::default()
.modal(true)
.title(title)
.multiple(options.multiple)
.directory(options.directories)
}
} else {
req
};

let request = match req2.send().await {
Ok(request) => request,
Err(err) => {
let result = match err {
Expand Down
1 change: 1 addition & 0 deletions crates/gpui/src/platform/test/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ impl Platform for TestPlatform {
fn prompt_for_paths(
&self,
_options: crate::PathPromptOptions,
_initial_path: Option<String>,
) -> oneshot::Receiver<Result<Option<Vec<std::path::PathBuf>>>> {
unimplemented!()
}
Expand Down
1 change: 1 addition & 0 deletions crates/workspace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ ui.workspace = true
util.workspace = true
uuid.workspace = true
zed_actions.workspace = true
zedless_settings.workspace = true
workspace-hack.workspace = true

[target.'cfg(target_os = "windows")'.dependencies]
Expand Down
8 changes: 6 additions & 2 deletions crates/workspace/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ pub use workspace_settings::{
AutosaveSetting, BottomDockLayout, RestoreOnStartupBehavior, TabBarSettings, WorkspaceSettings,
};
use zed_actions::{Spawn, feedback::FileBugReport};
use zedless_settings::ZedlessSettings;

use crate::notifications::NotificationId;
use crate::persistence::{
Expand Down Expand Up @@ -511,7 +512,7 @@ pub fn init_settings(cx: &mut App) {
}

fn prompt_and_open_paths(app_state: Arc<AppState>, options: PathPromptOptions, cx: &mut App) {
let paths = cx.prompt_for_paths(options);
let paths = cx.prompt_for_paths(options, None);
cx.spawn(
async move |cx| match paths.await.anyhow().and_then(|res| res) {
Ok(Some(paths)) => {
Expand Down Expand Up @@ -2024,14 +2025,17 @@ impl Workspace {
window: &mut Window,
cx: &mut Context<Self>,
) -> oneshot::Receiver<Option<Vec<PathBuf>>> {
let initial_path = ZedlessSettings::get_global(cx)
.projects_base_path
.clone();
if !lister.is_local(cx) || !WorkspaceSettings::get_global(cx).use_system_path_prompts {
let prompt = self.on_prompt_for_open_path.take().unwrap();
let rx = prompt(self, lister, window, cx);
self.on_prompt_for_open_path = Some(prompt);
rx
} else {
let (tx, rx) = oneshot::channel();
let abs_path = cx.prompt_for_paths(path_prompt_options);
let abs_path = cx.prompt_for_paths(path_prompt_options, initial_path);

cx.spawn_in(window, async move |workspace, cx| {
let Ok(result) = abs_path.await else {
Expand Down
2 changes: 2 additions & 0 deletions crates/zedless_settings/src/zedless_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub struct ZedlessSettings {
#[serde(default)]
/// Zeta server URL.
pub zeta_url: Option<String>,
/// Starting path for path prompts.
pub projects_base_path: Option<String>,
}

impl Settings for ZedlessSettings {
Expand Down