Adjust "recent projects" modal behavior to allow opening projects in both current and new window (#8267)

![image](https://github.com/zed-industries/zed/assets/2690773/7a0927e8-f32a-4502-8a8a-c7f8e5f325bb)

Fixes https://github.com/zed-industries/zed/issues/7419 by changing the
way "recent projects" modal confirm actions work:
* `menu::Confirm` now reuses the current window when opening a recent
project
* `menu::SecondaryConfirm` now opens a recent project in the new window 
* neither confirm tries to open the current project anymore
* modal's placeholder is adjusted to emphasize this behavior

Release Notes:

- Added a way to open recent projects in the new window
This commit is contained in:
Kirill Bulatov 2024-02-23 13:17:31 +02:00 committed by GitHub
parent a588f674db
commit 71557f3eb3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 30 additions and 10 deletions

View file

@ -1387,7 +1387,9 @@ impl Workspace {
};
if let Some(task) = this
.update(&mut cx, |this, cx| this.open_workspace_for_paths(paths, cx))
.update(&mut cx, |this, cx| {
this.open_workspace_for_paths(false, paths, cx)
})
.log_err()
{
task.await.log_err();
@ -1398,6 +1400,7 @@ impl Workspace {
pub fn open_workspace_for_paths(
&mut self,
replace_current_window: bool,
paths: Vec<PathBuf>,
cx: &mut ViewContext<Self>,
) -> Task<Result<()>> {
@ -1405,7 +1408,10 @@ impl Workspace {
let is_remote = self.project.read(cx).is_remote();
let has_worktree = self.project.read(cx).worktrees().next().is_some();
let has_dirty_items = self.items(cx).any(|item| item.is_dirty(cx));
let window_to_replace = if is_remote || has_worktree || has_dirty_items {
let window_to_replace = if replace_current_window {
window
} else if is_remote || has_worktree || has_dirty_items {
None
} else {
window