Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Use suggested name for `"use_system_path_prompts": false` dialogue when creating new files (#47802)
Kirill Bulatov4ea2c0923fa9
diff --git a/crates/open_path_prompt/src/open_path_prompt.rs b/crates/open_path_prompt/src/open_path_prompt.rsindex dcc797baf89..6c2608113bd 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>,) {- 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<String>,tx: oneshot::Sender<Option<Vec<PathBuf>>>,window: &mut Window,cx: &mut Context<Workspace>,@@ -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<String>,+ tx: oneshot::Sender<Option<Vec<PathBuf>>>,+ window: &mut Window,+ cx: &mut Context<Workspace>,+ ) {+ 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.rsindex 9c27841b65f..04db0a0d6a7 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<String>,&mut Window,&mut Context<Workspace>,) -> oneshot::Receiver<Option<Vec<PathBuf>>>,@@ -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})?;