From f4520d4184251b787db70ccee4403154b308a437 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 18 Mar 2022 18:07:03 +0100 Subject: [PATCH] WIP --- crates/editor/src/editor.rs | 2 +- crates/editor/src/items.rs | 4 ++-- crates/workspace/src/workspace.rs | 21 +++++++++++++++------ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 00aa8283254a8465b11b99385dbf570fc4ec5715..3f1c9c5fd2aacbf53f6687c280b902cc03120d64 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -341,7 +341,7 @@ pub fn init(cx: &mut MutableAppContext) { cx.add_async_action(Editor::find_all_references); workspace::register_project_item::(cx); - workspace::register_followed_item::(cx); + workspace::register_followable_item::(cx); } trait SelectionExt { diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 7d89341c0d339ee35875ed772955330fdfa1747d..410ffcddca38f4127605023689eec593d5a066d9 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -11,10 +11,10 @@ use std::{fmt::Write, path::PathBuf}; use text::{Point, Selection}; use util::ResultExt; use workspace::{ - FollowedItem, Item, ItemHandle, ItemNavHistory, ProjectItem, Settings, StatusItemView, + FollowableItem, Item, ItemHandle, ItemNavHistory, ProjectItem, Settings, StatusItemView, }; -impl FollowedItem for Editor { +impl FollowableItem for Editor { fn for_state_message( pane: ViewHandle, project: ModelHandle, diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 3cbd167319d06e364c62b0fe6f31b1d1171adf05..b011566c0fbe93a7065b896c0a8c402068967e27 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -131,7 +131,7 @@ pub fn register_project_item(cx: &mut MutableAppContext) { }); } -pub fn register_followed_item(cx: &mut MutableAppContext) { +pub fn register_followable_item(cx: &mut MutableAppContext) { cx.update_default_global(|builders: &mut FollowedItemBuilders, _| { builders.insert( TypeId::of::(), @@ -234,7 +234,7 @@ pub trait ProjectItem: Item { ) -> Self; } -pub trait FollowedItem: Item { +pub trait FollowableItem: Item { fn for_state_message( pane: ViewHandle, project: ModelHandle, @@ -261,7 +261,7 @@ pub trait FollowedItemHandle { ) -> Option; } -impl FollowedItemHandle for ViewHandle { +impl FollowedItemHandle for ViewHandle { fn id(&self) -> usize { self.id() } @@ -586,7 +586,12 @@ struct LeaderState { struct FollowerState { active_view_id: Option, - items_by_leader_view_id: HashMap>, + items_by_leader_view_id: HashMap, +} + +enum FollowerItem { + Loading(Vec), + Loaded(Box), } impl Workspace { @@ -1524,12 +1529,16 @@ impl Workspace { .ok_or_else(|| anyhow!("invalid update"))? { proto::update_followers::Variant::UpdateActiveView(update_active_view) => { - for (pane, state) in follower_states { + for state in follower_states.values_mut() { state.active_view_id = update_active_view.id.map(|id| id as usize); } } + proto::update_followers::Variant::UpdateView(update_view) => { + for state in follower_states.values_mut() { + state.items_by_leader_view_id.get(k) + } + } proto::update_followers::Variant::CreateView(_) => todo!(), - proto::update_followers::Variant::UpdateView(_) => todo!(), } this.leader_updated(leader_id, cx);