Hide cursor both locally and remotely when following
This commit is contained in:
parent
0e920ad5e9
commit
a2dbebd9ba
3 changed files with 31 additions and 2 deletions
|
@ -464,6 +464,7 @@ pub struct Editor {
|
||||||
pending_rename: Option<RenameState>,
|
pending_rename: Option<RenameState>,
|
||||||
searchable: bool,
|
searchable: bool,
|
||||||
cursor_shape: CursorShape,
|
cursor_shape: CursorShape,
|
||||||
|
following: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EditorSnapshot {
|
pub struct EditorSnapshot {
|
||||||
|
@ -937,6 +938,7 @@ impl Editor {
|
||||||
searchable: true,
|
searchable: true,
|
||||||
override_text_style: None,
|
override_text_style: None,
|
||||||
cursor_shape: Default::default(),
|
cursor_shape: Default::default(),
|
||||||
|
following: false,
|
||||||
};
|
};
|
||||||
this.end_selection(cx);
|
this.end_selection(cx);
|
||||||
this
|
this
|
||||||
|
@ -5036,7 +5038,7 @@ impl Editor {
|
||||||
|
|
||||||
self.selections = selections;
|
self.selections = selections;
|
||||||
self.pending_selection = pending_selection;
|
self.pending_selection = pending_selection;
|
||||||
if self.focused {
|
if self.focused && !self.following {
|
||||||
self.buffer.update(cx, |buffer, cx| {
|
self.buffer.update(cx, |buffer, cx| {
|
||||||
buffer.set_active_selections(&self.selections, cx)
|
buffer.set_active_selections(&self.selections, cx)
|
||||||
});
|
});
|
||||||
|
@ -5671,7 +5673,9 @@ impl View for Editor {
|
||||||
self.blink_cursors(self.blink_epoch, cx);
|
self.blink_cursors(self.blink_epoch, cx);
|
||||||
self.buffer.update(cx, |buffer, cx| {
|
self.buffer.update(cx, |buffer, cx| {
|
||||||
buffer.finalize_last_transaction(cx);
|
buffer.finalize_last_transaction(cx);
|
||||||
buffer.set_active_selections(&self.selections, cx)
|
if !self.following {
|
||||||
|
buffer.set_active_selections(&self.selections, cx);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,24 @@ impl FollowableItem for Editor {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_following(&mut self, following: bool, cx: &mut ViewContext<Self>) {
|
||||||
|
self.following = following;
|
||||||
|
if self.following {
|
||||||
|
self.show_local_selections = false;
|
||||||
|
self.buffer.update(cx, |buffer, cx| {
|
||||||
|
buffer.remove_active_selections(cx);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
self.show_local_selections = true;
|
||||||
|
if self.focused {
|
||||||
|
self.buffer.update(cx, |buffer, cx| {
|
||||||
|
buffer.set_active_selections(&self.selections, cx);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
|
||||||
fn to_state_message(&self, cx: &AppContext) -> Option<proto::view::Variant> {
|
fn to_state_message(&self, cx: &AppContext) -> Option<proto::view::Variant> {
|
||||||
let buffer_id = self.buffer.read(cx).as_singleton()?.read(cx).remote_id();
|
let buffer_id = self.buffer.read(cx).as_singleton()?.read(cx).remote_id();
|
||||||
Some(proto::view::Variant::Editor(proto::view::Editor {
|
Some(proto::view::Variant::Editor(proto::view::Editor {
|
||||||
|
|
|
@ -250,6 +250,7 @@ pub trait FollowableItem: Item {
|
||||||
state: &mut Option<proto::view::Variant>,
|
state: &mut Option<proto::view::Variant>,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut MutableAppContext,
|
||||||
) -> Option<Task<Result<ViewHandle<Self>>>>;
|
) -> Option<Task<Result<ViewHandle<Self>>>>;
|
||||||
|
fn set_following(&mut self, following: bool, cx: &mut ViewContext<Self>);
|
||||||
fn to_state_message(&self, cx: &AppContext) -> Option<proto::view::Variant>;
|
fn to_state_message(&self, cx: &AppContext) -> Option<proto::view::Variant>;
|
||||||
fn to_update_message(
|
fn to_update_message(
|
||||||
&self,
|
&self,
|
||||||
|
@ -264,6 +265,7 @@ pub trait FollowableItem: Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait FollowableItemHandle: ItemHandle {
|
pub trait FollowableItemHandle: ItemHandle {
|
||||||
|
fn set_following(&self, following: bool, cx: &mut MutableAppContext);
|
||||||
fn to_state_message(&self, cx: &AppContext) -> Option<proto::view::Variant>;
|
fn to_state_message(&self, cx: &AppContext) -> Option<proto::view::Variant>;
|
||||||
fn to_update_message(
|
fn to_update_message(
|
||||||
&self,
|
&self,
|
||||||
|
@ -278,6 +280,10 @@ pub trait FollowableItemHandle: ItemHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: FollowableItem> FollowableItemHandle for ViewHandle<T> {
|
impl<T: FollowableItem> FollowableItemHandle for ViewHandle<T> {
|
||||||
|
fn set_following(&self, following: bool, cx: &mut MutableAppContext) {
|
||||||
|
self.update(cx, |this, cx| this.set_following(following, cx))
|
||||||
|
}
|
||||||
|
|
||||||
fn to_state_message(&self, cx: &AppContext) -> Option<proto::view::Variant> {
|
fn to_state_message(&self, cx: &AppContext) -> Option<proto::view::Variant> {
|
||||||
self.read(cx).to_state_message(cx)
|
self.read(cx).to_state_message(cx)
|
||||||
}
|
}
|
||||||
|
@ -1267,6 +1273,7 @@ impl Workspace {
|
||||||
let state = this.follower_states_by_leader.entry(leader_id).or_default();
|
let state = this.follower_states_by_leader.entry(leader_id).or_default();
|
||||||
state.panes.insert(pane);
|
state.panes.insert(pane);
|
||||||
for (id, item) in leader_view_ids.into_iter().zip(items) {
|
for (id, item) in leader_view_ids.into_iter().zip(items) {
|
||||||
|
item.set_following(true, cx);
|
||||||
match state.items_by_leader_view_id.entry(id) {
|
match state.items_by_leader_view_id.entry(id) {
|
||||||
hash_map::Entry::Occupied(e) => {
|
hash_map::Entry::Occupied(e) => {
|
||||||
let e = e.into_mut();
|
let e = e.into_mut();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue