Move project browser toggling logic in workspace::open_paths
This commit is contained in:
parent
bba65e120d
commit
9730213ed7
4 changed files with 26 additions and 27 deletions
|
@ -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 {
|
||||
|
|
|
@ -360,8 +360,10 @@ mod tests {
|
|||
.await;
|
||||
assert_eq!(cx.window_ids().len(), 1);
|
||||
let workspace_1 = cx.root_view::<Workspace>(cx.window_ids()[0]).unwrap();
|
||||
workspace_1.read_with(cx, |workspace, cx| {
|
||||
assert_eq!(workspace.worktrees(cx).count(), 2)
|
||||
workspace_1.update(cx, |workspace, cx| {
|
||||
assert_eq!(workspace.worktrees(cx).count(), 2);
|
||||
assert!(workspace.left_sidebar_mut().active_item().is_some());
|
||||
assert!(workspace.active_pane().is_focused(cx));
|
||||
});
|
||||
|
||||
cx.update(|cx| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue