Finalize the CLI opening part
This commit is contained in:
parent
0c6f103899
commit
be7a58b508
3 changed files with 17 additions and 40 deletions
|
@ -203,8 +203,6 @@ impl SerializedPane {
|
||||||
|
|
||||||
items.push(item_handle.clone());
|
items.push(item_handle.clone());
|
||||||
|
|
||||||
log::info!("ACTUALLY SHOWN ITEMS: {:?}", &item_handle);
|
|
||||||
|
|
||||||
if let Some(item_handle) = item_handle {
|
if let Some(item_handle) = item_handle {
|
||||||
workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
let pane_handle = pane_handle
|
let pane_handle = pane_handle
|
||||||
|
|
|
@ -681,10 +681,7 @@ impl Workspace {
|
||||||
cx.spawn(|mut cx| async move {
|
cx.spawn(|mut cx| async move {
|
||||||
let serialized_workspace = persistence::DB.workspace_for_roots(&abs_paths.as_slice());
|
let serialized_workspace = persistence::DB.workspace_for_roots(&abs_paths.as_slice());
|
||||||
|
|
||||||
let paths_to_open = serialized_workspace
|
let paths_to_open = Arc::new(abs_paths);
|
||||||
.as_ref()
|
|
||||||
.map(|workspace| workspace.location.paths())
|
|
||||||
.unwrap_or(Arc::new(abs_paths));
|
|
||||||
|
|
||||||
// Get project paths for all of the abs_paths
|
// Get project paths for all of the abs_paths
|
||||||
let mut worktree_roots: HashSet<Arc<Path>> = Default::default();
|
let mut worktree_roots: HashSet<Arc<Path>> = Default::default();
|
||||||
|
@ -1074,6 +1071,8 @@ impl Workspace {
|
||||||
visible: bool,
|
visible: bool,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Task<Vec<Option<Result<Box<dyn ItemHandle>, anyhow::Error>>>> {
|
) -> Task<Vec<Option<Result<Box<dyn ItemHandle>, anyhow::Error>>>> {
|
||||||
|
log::info!("open paths {:?}", abs_paths);
|
||||||
|
|
||||||
let fs = self.app_state.fs.clone();
|
let fs = self.app_state.fs.clone();
|
||||||
|
|
||||||
// Sort the paths to ensure we add worktrees for parents before their children.
|
// Sort the paths to ensure we add worktrees for parents before their children.
|
||||||
|
@ -2512,25 +2511,23 @@ impl Workspace {
|
||||||
let dock_items = serialized_workspace
|
let dock_items = serialized_workspace
|
||||||
.dock_pane
|
.dock_pane
|
||||||
.deserialize_to(
|
.deserialize_to(
|
||||||
&project,
|
&project,
|
||||||
&dock_pane_handle,
|
&dock_pane_handle,
|
||||||
serialized_workspace.id,
|
serialized_workspace.id,
|
||||||
&workspace,
|
&workspace,
|
||||||
&mut cx,
|
&mut cx,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Traverse the splits tree and add to things
|
|
||||||
let something = serialized_workspace
|
|
||||||
.center_group
|
|
||||||
.deserialize(&project, serialized_workspace.id, &workspace, &mut cx)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
let mut center_items = None;
|
let mut center_items = None;
|
||||||
let mut center_group = None;
|
let mut center_group = None;
|
||||||
if let Some((group, active_pane, items)) = something {
|
// Traverse the splits tree and add to things
|
||||||
center_items = Some(items);
|
if let Some((group, active_pane, items)) = serialized_workspace
|
||||||
center_group = Some((group, active_pane))
|
.center_group
|
||||||
|
.deserialize(&project, serialized_workspace.id, &workspace, &mut cx)
|
||||||
|
.await {
|
||||||
|
center_items = Some(items);
|
||||||
|
center_group = Some((group, active_pane))
|
||||||
}
|
}
|
||||||
|
|
||||||
let resulting_list = cx.read(|cx| {
|
let resulting_list = cx.read(|cx| {
|
||||||
|
@ -2584,7 +2581,7 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
|
|
||||||
if workspace.left_sidebar().read(cx).is_open()
|
if workspace.left_sidebar().read(cx).is_open()
|
||||||
!= serialized_workspace.left_sidebar_open
|
!= serialized_workspace.left_sidebar_open
|
||||||
{
|
{
|
||||||
workspace.toggle_sidebar(SidebarSide::Left, cx);
|
workspace.toggle_sidebar(SidebarSide::Left, cx);
|
||||||
}
|
}
|
||||||
|
@ -2641,13 +2638,6 @@ async fn open_items(
|
||||||
let mut opened_items = Vec::with_capacity(project_paths_to_open.len());
|
let mut opened_items = Vec::with_capacity(project_paths_to_open.len());
|
||||||
|
|
||||||
if let Some(serialized_workspace) = serialized_workspace {
|
if let Some(serialized_workspace) = serialized_workspace {
|
||||||
// TODO kb
|
|
||||||
// If the user is opening a serialized workspace, force open the requested paths
|
|
||||||
// Requested items: (CLI args or whatever)
|
|
||||||
// Restored items: What came from the database
|
|
||||||
// Remaining items = Requested - restored
|
|
||||||
// For each remaining item, call workspace.open_path() (as below)
|
|
||||||
|
|
||||||
let workspace = workspace.clone();
|
let workspace = workspace.clone();
|
||||||
let restored_items = cx
|
let restored_items = cx
|
||||||
.update(|cx| {
|
.update(|cx| {
|
||||||
|
@ -2656,7 +2646,7 @@ async fn open_items(
|
||||||
serialized_workspace,
|
serialized_workspace,
|
||||||
project_paths_to_open
|
project_paths_to_open
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_, project_path)| project_path)
|
.map(|(_, project_path)| dbg!(project_path))
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect(),
|
.collect(),
|
||||||
cx,
|
cx,
|
||||||
|
@ -2966,8 +2956,6 @@ pub fn open_paths(
|
||||||
Vec<Option<Result<Box<dyn ItemHandle>, anyhow::Error>>>,
|
Vec<Option<Result<Box<dyn ItemHandle>, anyhow::Error>>>,
|
||||||
)>,
|
)>,
|
||||||
> {
|
> {
|
||||||
log::info!("open paths {:?}", abs_paths);
|
|
||||||
|
|
||||||
let app_state = app_state.clone();
|
let app_state = app_state.clone();
|
||||||
let abs_paths = abs_paths.to_vec();
|
let abs_paths = abs_paths.to_vec();
|
||||||
cx.spawn(|mut cx| async move {
|
cx.spawn(|mut cx| async move {
|
||||||
|
|
|
@ -729,19 +729,11 @@ async fn handle_cli_connection(
|
||||||
for (item, path) in items.into_iter().zip(&paths) {
|
for (item, path) in items.into_iter().zip(&paths) {
|
||||||
match item {
|
match item {
|
||||||
Some(Ok(item)) => {
|
Some(Ok(item)) => {
|
||||||
log::info!("UPDATED ITEMS: {:?}", item);
|
|
||||||
log::info!(
|
|
||||||
"caret_positions: {caret_positions:?}, path: {path:?}",
|
|
||||||
);
|
|
||||||
if let Some(point) = caret_positions.remove(path) {
|
if let Some(point) = caret_positions.remove(path) {
|
||||||
// TODO kb does not work
|
|
||||||
log::info!("@@@@@@@@ {path:?}@{point:?}");
|
|
||||||
if let Some(active_editor) = item.downcast::<Editor>() {
|
if let Some(active_editor) = item.downcast::<Editor>() {
|
||||||
log::info!("@@@@@@@@ editor");
|
|
||||||
active_editor
|
active_editor
|
||||||
.downgrade()
|
.downgrade()
|
||||||
.update(&mut cx, |editor, cx| {
|
.update(&mut cx, |editor, cx| {
|
||||||
log::info!("@@@@@@@@ update");
|
|
||||||
let snapshot =
|
let snapshot =
|
||||||
editor.snapshot(cx).display_snapshot;
|
editor.snapshot(cx).display_snapshot;
|
||||||
let point = snapshot
|
let point = snapshot
|
||||||
|
@ -752,7 +744,6 @@ async fn handle_cli_connection(
|
||||||
cx,
|
cx,
|
||||||
|s| s.select_ranges([point..point]),
|
|s| s.select_ranges([point..point]),
|
||||||
);
|
);
|
||||||
log::info!("@@@@@@@@ finished");
|
|
||||||
})
|
})
|
||||||
.log_err();
|
.log_err();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue