From fc8749ffd796cdfd19ea21df1a2d126b4f960fd6 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Fri, 5 Jul 2024 11:33:31 +0200 Subject: [PATCH] linux: Set directory in SaveFileRequest dialog (#13850) This has been bugging me for a while. If you create a new file and then save it, the dialogue would show the home directory and not the folder that you were in. This fixes it. Release Notes: - N/A --- crates/gpui/src/platform/linux/platform.rs | 29 ++++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/crates/gpui/src/platform/linux/platform.rs b/crates/gpui/src/platform/linux/platform.rs index 9eef459d5d..0e46419b39 100644 --- a/crates/gpui/src/platform/linux/platform.rs +++ b/crates/gpui/src/platform/linux/platform.rs @@ -314,20 +314,27 @@ impl Platform for P { let directory = directory.to_owned(); self.foreground_executor() .spawn(async move { - let result = SaveFileRequest::default() + let request = SaveFileRequest::default() .modal(true) .title("Select new path") .accept_label("Accept") - .send() - .await - .ok() - .and_then(|request| request.response().ok()) - .and_then(|response| { - response - .uris() - .first() - .and_then(|uri| uri.to_file_path().ok()) - }); + .current_folder(directory); + + let result = if let Ok(request) = request { + request + .send() + .await + .ok() + .and_then(|request| request.response().ok()) + .and_then(|response| { + response + .uris() + .first() + .and_then(|uri| uri.to_file_path().ok()) + }) + } else { + None + }; done_tx.send(result); })