History

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

Thorsten Ball committed 2 years ago

Commit fc8749f1 parent 2a923e31 file · +18 −11Browse files

Unified · Split

crates/gpui/src/platform/linux/platform.rs+18−11
@@ -314,20 +314,27 @@ impl<P: LinuxClient + 'static> Platform for P { · 313 unmodified lines
314314 let directory = directory.to_owned();
315315 self.foreground_executor()
316316 .spawn(async move {
317− let result = SaveFileRequest::default()
317+ let request = SaveFileRequest::default()
318318 .modal(true)
319319 .title("Select new path")
320320 .accept_label("Accept")
321− .send()
322− .await
323− .ok()
324− .and_then(|request| request.response().ok())
325− .and_then(|response| {
326− response
327− .uris()
328− .first()
329− .and_then(|uri| uri.to_file_path().ok())
330− });
321+ .current_folder(directory);
322+
323+ let result = if let Ok(request) = request {
324+ request
325+ .send()
326+ .await
327+ .ok()
328+ .and_then(|request| request.response().ok())
329+ .and_then(|response| {
330+ response
331+ .uris()
332+ .first()
333+ .and_then(|uri| uri.to_file_path().ok())
334+ })
335+ } else {
336+ None
337+ };
331338
332339 done_tx.send(result);
333340 })