Move project browser toggling logic in workspace::open_paths

This commit is contained in:
Antonio Scandurra 2022-04-22 11:25:23 +02:00
parent bba65e120d
commit 9730213ed7
4 changed files with 26 additions and 27 deletions

View file

@ -22,11 +22,7 @@ use smol::process::Command;
use std::{env, fs, path::PathBuf, sync::Arc, thread, time::Duration};
use theme::{ThemeRegistry, DEFAULT_THEME_NAME};
use util::ResultExt;
use workspace::{
self,
sidebar::{Side, SidebarItemId, ToggleSidebarItem},
AppState, OpenNew, OpenPaths,
};
use workspace::{self, AppState, OpenNew, OpenPaths};
use zed::{
self, build_window_options, build_workspace,
fs::RealFs,
@ -366,12 +362,11 @@ async fn handle_cli_connection(
if let Some(request) = requests.next().await {
match request {
CliRequest::Open { paths, wait } => {
let (workspace, items, is_new_workspace) = cx
let (workspace, items) = cx
.update(|cx| workspace::open_paths(&paths, &app_state, cx))
.await;
let mut errored = false;
let mut opened_directory = false;
let mut item_release_futures = Vec::new();
cx.update(|cx| {
for (item, path) in items.into_iter().zip(&paths) {
@ -395,23 +390,11 @@ async fn handle_cli_connection(
.log_err();
errored = true;
}
None => opened_directory = true,
None => {}
}
}
});
if opened_directory && is_new_workspace {
workspace.update(&mut cx, |workspace, cx| {
workspace.toggle_sidebar_item(
&ToggleSidebarItem(SidebarItemId {
side: Side::Left,
item_index: 0,
}),
cx,
);
});
}
if wait {
let background = cx.background();
let wait = async move {