From 4ea2c0923fa9c59a16e64cfd73db3e373abe343b Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 27 Jan 2026 22:54:20 +0200 Subject: [PATCH] Use suggested name for `"use_system_path_prompts": false` dialogue when creating new files (#47802) image Release Notes: - N/A --- .../open_path_prompt/src/open_path_prompt.rs | 31 ++++++++++++++----- crates/workspace/src/workspace.rs | 5 +-- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/crates/open_path_prompt/src/open_path_prompt.rs b/crates/open_path_prompt/src/open_path_prompt.rs index dcc797baf890d72455b0aaf160c10d9cbad71d9e..6c2608113bd4690886f784cdb50b4a05e75705b8 100644 --- a/crates/open_path_prompt/src/open_path_prompt.rs +++ b/crates/open_path_prompt/src/open_path_prompt.rs @@ -196,7 +196,7 @@ impl OpenPathPrompt { ) { workspace.set_prompt_for_open_path(Box::new(|workspace, lister, window, cx| { let (tx, rx) = futures::channel::oneshot::channel(); - Self::prompt_for_open_path(workspace, lister, false, tx, window, cx); + Self::prompt_for_open_path(workspace, lister, false, None, tx, window, cx); rx })); } @@ -206,17 +206,20 @@ impl OpenPathPrompt { _window: Option<&mut Window>, _: &mut Context, ) { - workspace.set_prompt_for_new_path(Box::new(|workspace, lister, window, cx| { - let (tx, rx) = futures::channel::oneshot::channel(); - Self::prompt_for_open_path(workspace, lister, true, tx, window, cx); - rx - })); + workspace.set_prompt_for_new_path(Box::new( + |workspace, lister, suggested_name, window, cx| { + let (tx, rx) = futures::channel::oneshot::channel(); + Self::prompt_for_new_path(workspace, lister, suggested_name, tx, window, cx); + rx + }, + )); } fn prompt_for_open_path( workspace: &mut Workspace, lister: DirectoryLister, creating_path: bool, + suggested_name: Option, tx: oneshot::Sender>>, window: &mut Window, cx: &mut Context, @@ -224,11 +227,25 @@ impl OpenPathPrompt { workspace.toggle_modal(window, cx, |window, cx| { let delegate = OpenPathDelegate::new(tx, lister.clone(), creating_path, cx); let picker = Picker::uniform_list(delegate, window, cx).width(rems(34.)); - let query = lister.default_query(cx); + let mut query = lister.default_query(cx); + if let Some(suggested_name) = suggested_name { + query.push_str(&suggested_name); + } picker.set_query(&query, window, cx); picker }); } + + fn prompt_for_new_path( + workspace: &mut Workspace, + lister: DirectoryLister, + suggested_name: Option, + tx: oneshot::Sender>>, + window: &mut Window, + cx: &mut Context, + ) { + Self::prompt_for_open_path(workspace, lister, true, suggested_name, tx, window, cx); + } } impl PickerDelegate for OpenPathDelegate { diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 9c27841b65f59d73497cc6611c418fb1b3656c04..04db0a0d6a704c789b6a493e21957f083031093c 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1147,6 +1147,7 @@ type PromptForNewPath = Box< dyn Fn( &mut Workspace, DirectoryLister, + Option, &mut Window, &mut Context, ) -> oneshot::Receiver>>, @@ -2392,7 +2393,7 @@ impl Workspace { || !WorkspaceSettings::get_global(cx).use_system_path_prompts { let prompt = self.on_prompt_for_new_path.take().unwrap(); - let rx = prompt(self, lister, window, cx); + let rx = prompt(self, lister, suggested_name, window, cx); self.on_prompt_for_new_path = Some(prompt); return rx; } @@ -2420,7 +2421,7 @@ impl Workspace { workspace.show_portal_error(err.to_string(), cx); let prompt = workspace.on_prompt_for_new_path.take().unwrap(); - let rx = prompt(workspace, lister, window, cx); + let rx = prompt(workspace, lister, suggested_name, window, cx); workspace.on_prompt_for_new_path = Some(prompt); rx })?;