Don't show conflict indicator on remote buffer after a reload
This commit is contained in:
parent
4372fe1ed0
commit
f859d444ff
6 changed files with 201 additions and 17 deletions
|
@ -299,6 +299,7 @@ impl Project {
|
|||
),
|
||||
client.subscribe_to_entity(remote_id, cx, Self::handle_update_buffer),
|
||||
client.subscribe_to_entity(remote_id, cx, Self::handle_update_buffer_file),
|
||||
client.subscribe_to_entity(remote_id, cx, Self::handle_buffer_reloaded),
|
||||
client.subscribe_to_entity(remote_id, cx, Self::handle_buffer_saved),
|
||||
],
|
||||
client,
|
||||
|
@ -1694,6 +1695,37 @@ impl Project {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn handle_buffer_reloaded(
|
||||
&mut self,
|
||||
envelope: TypedEnvelope<proto::BufferReloaded>,
|
||||
_: Arc<Client>,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Result<()> {
|
||||
let payload = envelope.payload.clone();
|
||||
let buffer = self
|
||||
.open_buffers
|
||||
.get(&(payload.buffer_id as usize))
|
||||
.and_then(|buf| {
|
||||
if let OpenBuffer::Loaded(buffer) = buf {
|
||||
buffer.upgrade(cx)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
if let Some(buffer) = buffer {
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
let version = payload.version.try_into()?;
|
||||
let mtime = payload
|
||||
.mtime
|
||||
.ok_or_else(|| anyhow!("missing mtime"))?
|
||||
.into();
|
||||
buffer.did_reload(version, mtime, cx);
|
||||
Result::<_, anyhow::Error>::Ok(())
|
||||
})?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn match_paths<'a>(
|
||||
&self,
|
||||
query: &'a str,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue