Use suggested name for "use_system_path_prompts": false dialogue when creating new files (#47802)

<img width="1419" height="266" alt="image"
src="https://github.com/user-attachments/assets/059ee9e2-e102-4fc6-acba-d66ae0292203"
/>


Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov authored and GitHub committed 2026-01-27 20:54:20 +00:00
1 parent 87d41c1d97
commit 4ea2c0923f
2 files changed
+27 -9

No files matched your search

@@ -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 {
+3 -2
View File
@@ -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
})?;