WIP
This commit is contained in:
parent
7d7e10598a
commit
f4520d4184
3 changed files with 18 additions and 9 deletions
|
@ -341,7 +341,7 @@ pub fn init(cx: &mut MutableAppContext) {
|
||||||
cx.add_async_action(Editor::find_all_references);
|
cx.add_async_action(Editor::find_all_references);
|
||||||
|
|
||||||
workspace::register_project_item::<Editor>(cx);
|
workspace::register_project_item::<Editor>(cx);
|
||||||
workspace::register_followed_item::<Editor>(cx);
|
workspace::register_followable_item::<Editor>(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
trait SelectionExt {
|
trait SelectionExt {
|
||||||
|
|
|
@ -11,10 +11,10 @@ use std::{fmt::Write, path::PathBuf};
|
||||||
use text::{Point, Selection};
|
use text::{Point, Selection};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::{
|
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(
|
fn for_state_message(
|
||||||
pane: ViewHandle<workspace::Pane>,
|
pane: ViewHandle<workspace::Pane>,
|
||||||
project: ModelHandle<Project>,
|
project: ModelHandle<Project>,
|
||||||
|
|
|
@ -131,7 +131,7 @@ pub fn register_project_item<I: ProjectItem>(cx: &mut MutableAppContext) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register_followed_item<I: FollowedItem>(cx: &mut MutableAppContext) {
|
pub fn register_followable_item<I: FollowableItem>(cx: &mut MutableAppContext) {
|
||||||
cx.update_default_global(|builders: &mut FollowedItemBuilders, _| {
|
cx.update_default_global(|builders: &mut FollowedItemBuilders, _| {
|
||||||
builders.insert(
|
builders.insert(
|
||||||
TypeId::of::<I>(),
|
TypeId::of::<I>(),
|
||||||
|
@ -234,7 +234,7 @@ pub trait ProjectItem: Item {
|
||||||
) -> Self;
|
) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait FollowedItem: Item {
|
pub trait FollowableItem: Item {
|
||||||
fn for_state_message(
|
fn for_state_message(
|
||||||
pane: ViewHandle<Pane>,
|
pane: ViewHandle<Pane>,
|
||||||
project: ModelHandle<Project>,
|
project: ModelHandle<Project>,
|
||||||
|
@ -261,7 +261,7 @@ pub trait FollowedItemHandle {
|
||||||
) -> Option<proto::update_followers::update_view::Variant>;
|
) -> Option<proto::update_followers::update_view::Variant>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: FollowedItem> FollowedItemHandle for ViewHandle<T> {
|
impl<T: FollowableItem> FollowedItemHandle for ViewHandle<T> {
|
||||||
fn id(&self) -> usize {
|
fn id(&self) -> usize {
|
||||||
self.id()
|
self.id()
|
||||||
}
|
}
|
||||||
|
@ -586,7 +586,12 @@ struct LeaderState {
|
||||||
|
|
||||||
struct FollowerState {
|
struct FollowerState {
|
||||||
active_view_id: Option<usize>,
|
active_view_id: Option<usize>,
|
||||||
items_by_leader_view_id: HashMap<usize, Box<dyn ItemHandle>>,
|
items_by_leader_view_id: HashMap<usize, FollowerItem>,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum FollowerItem {
|
||||||
|
Loading(Vec<proto::update_followers::Variant>),
|
||||||
|
Loaded(Box<dyn FollowedItemHandle>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Workspace {
|
impl Workspace {
|
||||||
|
@ -1524,12 +1529,16 @@ impl Workspace {
|
||||||
.ok_or_else(|| anyhow!("invalid update"))?
|
.ok_or_else(|| anyhow!("invalid update"))?
|
||||||
{
|
{
|
||||||
proto::update_followers::Variant::UpdateActiveView(update_active_view) => {
|
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);
|
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::CreateView(_) => todo!(),
|
||||||
proto::update_followers::Variant::UpdateView(_) => todo!(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.leader_updated(leader_id, cx);
|
this.leader_updated(leader_id, cx);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue