Suggest unsaved buffer content text as the default filename (#35707)
Closes #24672 This PR complements a feature added earlier by @JosephTLyons (in https://github.com/zed-industries/zed/pull/32353) where the text is considered as the tab title in a new buffer. It piggybacks off that change and sets the title as the suggested filename in the save dialog (completely mirroring the same functionality in VSCode):  Release Notes: - Text entered in a new untitled buffer is considered as the default filename when saving
This commit is contained in:
parent
485802b9e5
commit
7993ee9c07
10 changed files with 75 additions and 18 deletions
|
@ -737,8 +737,13 @@ impl Platform for MacPlatform {
|
|||
done_rx
|
||||
}
|
||||
|
||||
fn prompt_for_new_path(&self, directory: &Path) -> oneshot::Receiver<Result<Option<PathBuf>>> {
|
||||
fn prompt_for_new_path(
|
||||
&self,
|
||||
directory: &Path,
|
||||
suggested_name: Option<&str>,
|
||||
) -> oneshot::Receiver<Result<Option<PathBuf>>> {
|
||||
let directory = directory.to_owned();
|
||||
let suggested_name = suggested_name.map(|s| s.to_owned());
|
||||
let (done_tx, done_rx) = oneshot::channel();
|
||||
self.foreground_executor()
|
||||
.spawn(async move {
|
||||
|
@ -748,6 +753,11 @@ impl Platform for MacPlatform {
|
|||
let url = NSURL::fileURLWithPath_isDirectory_(nil, path, true.to_objc());
|
||||
panel.setDirectoryURL(url);
|
||||
|
||||
if let Some(suggested_name) = suggested_name {
|
||||
let name_string = ns_string(&suggested_name);
|
||||
let _: () = msg_send![panel, setNameFieldStringValue: name_string];
|
||||
}
|
||||
|
||||
let done_tx = Cell::new(Some(done_tx));
|
||||
let block = ConcreteBlock::new(move |response: NSModalResponse| {
|
||||
let mut result = None;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue