Allow FollowableItem::to_state_message to return None
This way, we can avoid a panic if we don't handle certain cases, like a non-singleton editor.
This commit is contained in:
parent
df0632011c
commit
d860ed25c1
2 changed files with 17 additions and 21 deletions
|
@ -50,21 +50,15 @@ impl FollowableItem for Editor {
|
|||
}))
|
||||
}
|
||||
|
||||
fn to_state_message(&self, cx: &AppContext) -> proto::view::Variant {
|
||||
let buffer_id = self
|
||||
.buffer
|
||||
.read(cx)
|
||||
.as_singleton()
|
||||
.unwrap()
|
||||
.read(cx)
|
||||
.remote_id();
|
||||
proto::view::Variant::Editor(proto::view::Editor {
|
||||
fn to_state_message(&self, cx: &AppContext) -> Option<proto::view::Variant> {
|
||||
let buffer_id = self.buffer.read(cx).as_singleton()?.read(cx).remote_id();
|
||||
Some(proto::view::Variant::Editor(proto::view::Editor {
|
||||
buffer_id,
|
||||
scroll_top: self
|
||||
.scroll_top_anchor
|
||||
.as_ref()
|
||||
.map(|anchor| language::proto::serialize_anchor(&anchor.text_anchor)),
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
fn to_update_message(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue